Refactor whitespace

Do various whitespace refactorings, of note:

- Use space around equals e.g., 'since = "blah"'
- Put return/break/continue on separate line

Whitespace only, no logic changes.
This commit is contained in:
Tobin Harding 2022-01-24 11:26:29 +11:00
parent 1c502399f1
commit bf4f5638e0
21 changed files with 90 additions and 78 deletions

View File

@ -674,7 +674,7 @@ impl fmt::Display for NonStandardSigHashType {
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl error::Error for NonStandardSigHashType {}
/// Legacy Hashtype of an input's signature.
/// Legacy Hashtype of an input's signature
#[deprecated(since = "0.28.0", note = "Please use [`EcdsaSigHashType`] instead")]
pub type SigHashType = EcdsaSigHashType;

View File

@ -439,7 +439,6 @@ impl Decodable for VarInt {
}
}
// Booleans
impl Encodable for bool {
#[inline]

View File

@ -385,4 +385,3 @@ mod tests {
assert_eq!("ServiceFlags(WITNESS|COMPACT_FILTERS|0xb0)", flag.to_string());
}
}

View File

@ -27,4 +27,3 @@ macro_rules! serde_round_trip (
assert_eq!($var, decoded);
})
);

View File

@ -31,7 +31,6 @@ use hashes::{Hash, hash160, hex, hex::FromHex};
use hash_types::{PubkeyHash, WPubkeyHash};
use util::base58;
/// A key-related error.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum Error {
@ -45,7 +44,6 @@ pub enum Error {
Hex(hex::Error)
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
@ -192,7 +190,9 @@ impl PublicKey {
let compressed: bool = match data.len() {
33 => true,
65 => false,
len => { return Err(base58::Error::InvalidLength(len).into()); },
len => {
return Err(base58::Error::InvalidLength(len).into());
},
};
if !compressed && data[0] != 0x04 {
@ -323,13 +323,17 @@ impl PrivateKey {
let compressed = match data.len() {
33 => false,
34 => true,
_ => { return Err(Error::Base58(base58::Error::InvalidLength(data.len()))); }
_ => {
return Err(Error::Base58(base58::Error::InvalidLength(data.len())));
}
};
let network = match data[0] {
128 => Network::Bitcoin,
239 => Network::Testnet,
x => { return Err(Error::Base58(base58::Error::InvalidAddressVersion(x))); }
x => {
return Err(Error::Base58(base58::Error::InvalidAddressVersion(x)));
}
};
Ok(PrivateKey {

View File

@ -217,8 +217,12 @@ mod message_signing {
/// instance of it, returning the number of instances removed.
/// Loops through the vector opcode by opcode, skipping pushed data.
pub fn script_find_and_remove(haystack: &mut Vec<u8>, needle: &[u8]) -> usize {
if needle.len() > haystack.len() { return 0; }
if needle.is_empty() { return 0; }
if needle.len() > haystack.len() {
return 0;
}
if needle.is_empty() {
return 0;
}
let mut top = haystack.len() - needle.len();
let mut n_deleted = 0;
@ -233,7 +237,9 @@ pub fn script_find_and_remove(haystack: &mut Vec<u8>, needle: &[u8]) -> usize {
// This is ugly but prevents infinite loop in case of overflow
let overflow = top < needle.len();
top = top.wrapping_sub(needle.len());
if overflow { break; }
if overflow {
break;
}
} else {
i += match opcodes::All::from((*haystack)[i]).classify(opcodes::ClassifyContext::Legacy) {
opcodes::Class::PushBytes(n) => n as usize + 1,

View File

@ -893,7 +893,6 @@ mod tests {
use super::*;
use super::serialize;
#[test]
fn invalid_vectors() {
let err = hex_psbt!("70736274ff010071020000000127744ababf3027fe0d6cf23a96eee2efb188ef52301954585883e69b6624b2420000000000ffffffff02787c01000000000016001483a7e34bd99ff03a4962ef8a1a101bb295461ece606b042a010000001600147ac369df1b20e033d6116623957b0ac49f3c52e8000000000001012b00f2052a010000002251205a2c2cf5b52cf31f83ad2e8da63ff03183ecd8f609c7510ae8a48e03910a075701172102fe349064c98d6e2a853fa3c9b12bd8b304a19c195c60efa7ee2393046d3fa232000000").unwrap_err();

View File

@ -169,7 +169,9 @@ macro_rules! construct_uint {
let &mut $name(ref mut arr) = self;
for i in 0..$n_words {
arr[i] = arr[i].wrapping_add(1);
if arr[i] != 0 { break; }
if arr[i] != 0 {
break;
}
}
}
}
@ -188,8 +190,12 @@ macro_rules! construct_uint {
// and the auto derive is a lexicographic ordering(i.e. memcmp)
// which with numbers is equivalent to big-endian
for i in 0..$n_words {
if self[$n_words - 1 - i] < other[$n_words - 1 - i] { return ::core::cmp::Ordering::Less; }
if self[$n_words - 1 - i] > other[$n_words - 1 - i] { return ::core::cmp::Ordering::Greater; }
if self[$n_words - 1 - i] < other[$n_words - 1 - i] {
return ::core::cmp::Ordering::Less;
}
if self[$n_words - 1 - i] > other[$n_words - 1 - i] {
return ::core::cmp::Ordering::Greater;
}
}
::core::cmp::Ordering::Equal
}