From 5af7727250a719a439742db5a3335adb20039cb2 Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 17 Dec 2023 00:59:05 +0000 Subject: [PATCH] 2023-12-17 automated rustfmt nightly --- bitcoin/examples/bip32.rs | 2 +- bitcoin/examples/ecdsa-psbt.rs | 4 +- bitcoin/examples/sighash.rs | 4 +- bitcoin/src/address/mod.rs | 14 ++--- bitcoin/src/bip32.rs | 2 +- bitcoin/src/blockdata/script/borrowed.rs | 24 ++++---- bitcoin/src/blockdata/script/tests.rs | 12 +++- bitcoin/src/blockdata/transaction.rs | 10 +-- bitcoin/src/consensus/validation.rs | 3 +- bitcoin/src/crypto/key.rs | 14 ++--- bitcoin/src/sign_message.rs | 3 +- bitcoin/src/taproot/merkle_branch.rs | 78 +++++++----------------- bitcoin/src/taproot/mod.rs | 2 +- internals/src/array_vec.rs | 63 ++++++++----------- io/src/lib.rs | 2 +- units/src/amount.rs | 8 +-- 16 files changed, 97 insertions(+), 148 deletions(-) diff --git a/bitcoin/examples/bip32.rs b/bitcoin/examples/bip32.rs index de027003..98642870 100644 --- a/bitcoin/examples/bip32.rs +++ b/bitcoin/examples/bip32.rs @@ -8,7 +8,7 @@ use bitcoin::bip32::{ChildNumber, DerivationPath, Xpriv, Xpub}; use bitcoin::hex::FromHex; use bitcoin::secp256k1::ffi::types::AlignedType; use bitcoin::secp256k1::Secp256k1; -use bitcoin::{Network, NetworkKind, CompressedPublicKey}; +use bitcoin::{CompressedPublicKey, Network, NetworkKind}; fn main() { // This example derives root xprv from a 32-byte seed, diff --git a/bitcoin/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs index 30f9d32d..895c6e99 100644 --- a/bitcoin/examples/ecdsa-psbt.rs +++ b/bitcoin/examples/ecdsa-psbt.rs @@ -39,8 +39,8 @@ use bitcoin::locktime::absolute; use bitcoin::psbt::{self, Input, Psbt, PsbtSighashType}; use bitcoin::secp256k1::{Secp256k1, Signing, Verification}; use bitcoin::{ - transaction, Address, Amount, Network, OutPoint, CompressedPublicKey, ScriptBuf, Sequence, Transaction, - TxIn, TxOut, Witness, + transaction, Address, Amount, CompressedPublicKey, Network, OutPoint, ScriptBuf, Sequence, + Transaction, TxIn, TxOut, Witness, }; type Result = std::result::Result; diff --git a/bitcoin/examples/sighash.rs b/bitcoin/examples/sighash.rs index 138e422d..bdddaa7e 100644 --- a/bitcoin/examples/sighash.rs +++ b/bitcoin/examples/sighash.rs @@ -1,5 +1,7 @@ use bitcoin::hashes::Hash; -use bitcoin::{consensus, ecdsa, sighash, Amount, CompressedPublicKey, Script, ScriptBuf, Transaction}; +use bitcoin::{ + consensus, ecdsa, sighash, Amount, CompressedPublicKey, Script, ScriptBuf, Transaction, +}; use hex_lit::hex; //These are real blockchain transactions examples of computing sighash for: diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index b1843824..79ae4c80 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -45,7 +45,9 @@ use crate::blockdata::constants::{ use crate::blockdata::script::witness_program::WitnessProgram; use crate::blockdata::script::witness_version::WitnessVersion; use crate::blockdata::script::{self, PushBytesBuf, Script, ScriptBuf, ScriptHash}; -use crate::crypto::key::{PubkeyHash, PublicKey, CompressedPublicKey, TweakedPublicKey, UntweakedPublicKey}; +use crate::crypto::key::{ + CompressedPublicKey, PubkeyHash, PublicKey, TweakedPublicKey, UntweakedPublicKey, +}; use crate::network::{Network, NetworkKind}; use crate::prelude::*; use crate::taproot::TapNodeHash; @@ -390,10 +392,7 @@ impl Address { /// Creates a witness pay to public key address from a public key. /// /// This is the native segwit address type for an output redeemable with a single signature. - pub fn p2wpkh( - pk: &CompressedPublicKey, - network: Network, - ) -> Self { + pub fn p2wpkh(pk: &CompressedPublicKey, network: Network) -> Self { let program = WitnessProgram::p2wpkh(pk); Address::from_witness_program(program, network) } @@ -401,10 +400,7 @@ impl Address { /// Creates a pay to script address that embeds a witness pay to public key. /// /// This is a segwit address type that looks familiar (as p2sh) to legacy clients. - pub fn p2shwpkh( - pk: &CompressedPublicKey, - network: impl Into, - ) -> Address { + pub fn p2shwpkh(pk: &CompressedPublicKey, network: impl Into) -> Address { let builder = script::Builder::new().push_int(0).push_slice(pk.wpubkey_hash()); let script_hash = builder.as_script().script_hash(); Address::p2sh_from_hash(script_hash, network) diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 5bda3575..6b8339bd 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -19,7 +19,7 @@ use secp256k1::{self, Secp256k1, XOnlyPublicKey}; use serde; use crate::base58; -use crate::crypto::key::{self, Keypair, PrivateKey, CompressedPublicKey}; +use crate::crypto::key::{self, CompressedPublicKey, Keypair, PrivateKey}; use crate::internal_macros::impl_bytes_newtype; use crate::network::NetworkKind; use crate::prelude::*; diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index 828a23b9..be47c91c 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -420,22 +420,22 @@ impl Script { fn minimal_non_dust_inner(&self, dust_relay_fee: u64) -> crate::Amount { // This must never be lower than Bitcoin Core's GetDustThreshold() (as of v0.21) as it may // otherwise allow users to create transactions which likely can never be broadcast/confirmed. - let sats = dust_relay_fee.checked_mul( - if self.is_op_return() { - 0 - } else if self.is_witness_program() { - 32 + 4 + 1 + (107 / 4) + 4 + // The spend cost copied from Core + let sats = dust_relay_fee + .checked_mul(if self.is_op_return() { + 0 + } else if self.is_witness_program() { + 32 + 4 + 1 + (107 / 4) + 4 + // The spend cost copied from Core 8 + // The serialized size of the TxOut's amount field self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey - } else { - 32 + 4 + 1 + 107 + 4 + // The spend cost copied from Core + } else { + 32 + 4 + 1 + 107 + 4 + // The spend cost copied from Core 8 + // The serialized size of the TxOut's amount field self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey - } - ).expect("dust_relay_fee or script length should not be absurdly large") / - 1000; // divide by 1000 like in Core to get value as it cancels out DEFAULT_MIN_RELAY_TX_FEE - // Note: We ensure the division happens at the end, since Core performs the division at the end. - // This will make sure none of the implicit floor operations mess with the value. + }) + .expect("dust_relay_fee or script length should not be absurdly large") + / 1000; // divide by 1000 like in Core to get value as it cancels out DEFAULT_MIN_RELAY_TX_FEE + // Note: We ensure the division happens at the end, since Core performs the division at the end. + // This will make sure none of the implicit floor operations mess with the value. crate::Amount::from_sat(sats) } diff --git a/bitcoin/src/blockdata/script/tests.rs b/bitcoin/src/blockdata/script/tests.rs index e0a60f4e..88c641d4 100644 --- a/bitcoin/src/blockdata/script/tests.rs +++ b/bitcoin/src/blockdata/script/tests.rs @@ -6,10 +6,10 @@ use hashes::Hash; use hex_lit::hex; use super::*; -use crate::FeeRate; use crate::blockdata::opcodes; use crate::consensus::encode::{deserialize, serialize}; use crate::crypto::key::{PubkeyHash, PublicKey, WPubkeyHash, XOnlyPublicKey}; +use crate::FeeRate; #[test] #[rustfmt::skip] @@ -651,7 +651,10 @@ fn defult_dust_value_tests() { let script_p2wpkh = Builder::new().push_int(0).push_slice([42; 20]).into_script(); assert!(script_p2wpkh.is_p2wpkh()); assert_eq!(script_p2wpkh.minimal_non_dust(), crate::Amount::from_sat(294)); - assert_eq!(script_p2wpkh.minimal_non_dust_custom(FeeRate::from_sat_per_vb_unchecked(6)), crate::Amount::from_sat(588)); + assert_eq!( + script_p2wpkh.minimal_non_dust_custom(FeeRate::from_sat_per_vb_unchecked(6)), + crate::Amount::from_sat(588) + ); let script_p2pkh = Builder::new() .push_opcode(OP_DUP) @@ -662,7 +665,10 @@ fn defult_dust_value_tests() { .into_script(); assert!(script_p2pkh.is_p2pkh()); assert_eq!(script_p2pkh.minimal_non_dust(), crate::Amount::from_sat(546)); - assert_eq!(script_p2pkh.minimal_non_dust_custom(FeeRate::from_sat_per_vb_unchecked(6)), crate::Amount::from_sat(1092)); + assert_eq!( + script_p2pkh.minimal_non_dust_custom(FeeRate::from_sat_per_vb_unchecked(6)), + crate::Amount::from_sat(1092) + ); } #[test] diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 62daaef6..44b3f32f 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -557,10 +557,7 @@ impl TxOut { /// /// [`minimal_non_dust_custom`]: TxOut::minimal_non_dust_custom pub fn minimal_non_dust(script_pubkey: ScriptBuf) -> Self { - TxOut { - value: script_pubkey.minimal_non_dust(), - script_pubkey, - } + TxOut { value: script_pubkey.minimal_non_dust(), script_pubkey } } /// Creates a `TxOut` with given script and the smallest possible `value` that is **not** dust @@ -575,10 +572,7 @@ impl TxOut { /// /// [`minimal_non_dust`]: TxOut::minimal_non_dust pub fn minimal_non_dust_custom(script_pubkey: ScriptBuf, dust_relay_fee: FeeRate) -> Self { - TxOut { - value: script_pubkey.minimal_non_dust_custom(dust_relay_fee), - script_pubkey, - } + TxOut { value: script_pubkey.minimal_non_dust_custom(dust_relay_fee), script_pubkey } } } diff --git a/bitcoin/src/consensus/validation.rs b/bitcoin/src/consensus/validation.rs index 883bec6c..e55a0bd0 100644 --- a/bitcoin/src/consensus/validation.rs +++ b/bitcoin/src/consensus/validation.rs @@ -57,7 +57,8 @@ pub fn verify_script_with_flags>( spending_tx, index, flags.into(), - ).map_err(BitcoinconsensusError) + ) + .map_err(BitcoinconsensusError) } /// Verifies that this transaction is able to spend its inputs. diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index 1960422c..9ee810cc 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -11,9 +11,9 @@ use core::str::FromStr; use hashes::{hash160, Hash}; use hex::FromHex; +use internals::array_vec::ArrayVec; use internals::write_err; use io::{Read, Write}; -use internals::array_vec::ArrayVec; use crate::crypto::ecdsa; use crate::internal_macros::impl_asref_push_bytes; @@ -299,9 +299,7 @@ impl CompressedPublicKey { /// /// Note that this can be used as a sort key to get BIP67-compliant sorting. /// That's why this type doesn't have the `to_sort_key` method - it would duplicate this one. - pub fn to_bytes(&self) -> [u8; 33] { - self.0.serialize() - } + pub fn to_bytes(&self) -> [u8; 33] { self.0.serialize() } /// Deserialize a public key from a slice pub fn from_slice(data: &[u8]) -> Result { @@ -354,9 +352,7 @@ impl TryFrom for CompressedPublicKey { } impl From for PublicKey { - fn from(value: CompressedPublicKey) -> Self { - PublicKey::new(value.0) - } + fn from(value: CompressedPublicKey) -> Self { PublicKey::new(value.0) } } impl From for XOnlyPublicKey { @@ -379,7 +375,6 @@ impl From<&CompressedPublicKey> for WPubkeyHash { fn from(key: &CompressedPublicKey) -> Self { key.wpubkey_hash() } } - /// A Bitcoin ECDSA private key #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct PrivateKey { @@ -1284,7 +1279,8 @@ mod tests { fn private_key_debug_is_obfuscated() { let sk = PrivateKey::from_str("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy").unwrap(); - let want = "PrivateKey { compressed: true, network: Test, inner: SecretKey(#32014e414fdce702) }"; + let want = + "PrivateKey { compressed: true, network: Test, inner: SecretKey(#32014e414fdce702) }"; let got = format!("{:?}", sk); assert_eq!(got, want) } diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs index c16bc810..40d15979 100644 --- a/bitcoin/src/sign_message.rs +++ b/bitcoin/src/sign_message.rs @@ -238,7 +238,8 @@ mod tests { assert_eq!(signature.to_base64(), signature.to_string()); let signature2 = super::MessageSignature::from_str(&signature.to_string()).unwrap(); - let pubkey = signature2.recover_pubkey(&secp, msg_hash) + let pubkey = signature2 + .recover_pubkey(&secp, msg_hash) .unwrap() .try_into() .expect("compressed was set to true"); diff --git a/bitcoin/src/taproot/merkle_branch.rs b/bitcoin/src/taproot/merkle_branch.rs index 83002d86..07e8e1c0 100644 --- a/bitcoin/src/taproot/merkle_branch.rs +++ b/bitcoin/src/taproot/merkle_branch.rs @@ -6,9 +6,13 @@ use alloc::boxed::Box; use alloc::vec::Vec; use core::borrow::{Borrow, BorrowMut}; -use super::{TapNodeHash, TaprootError, TaprootBuilderError, TAPROOT_CONTROL_NODE_SIZE, TAPROOT_CONTROL_MAX_NODE_COUNT}; use hashes::Hash; +use super::{ + TapNodeHash, TaprootBuilderError, TaprootError, TAPROOT_CONTROL_MAX_NODE_COUNT, + TAPROOT_CONTROL_NODE_SIZE, +}; + /// The merkle proof for inclusion of a tree in a taptree hash. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] @@ -169,9 +173,7 @@ impl IntoIterator for TaprootMerkleBranch { type Item = TapNodeHash; #[inline] - fn into_iter(self) -> Self::IntoIter { - IntoIter(self.0.into_iter()) - } + fn into_iter(self) -> Self::IntoIter { IntoIter(self.0.into_iter()) } } impl<'a> IntoIterator for &'a TaprootMerkleBranch { @@ -179,9 +181,7 @@ impl<'a> IntoIterator for &'a TaprootMerkleBranch { type Item = &'a TapNodeHash; #[inline] - fn into_iter(self) -> Self::IntoIter { - self.0.iter() - } + fn into_iter(self) -> Self::IntoIter { self.0.iter() } } impl<'a> IntoIterator for &'a mut TaprootMerkleBranch { @@ -189,53 +189,39 @@ impl<'a> IntoIterator for &'a mut TaprootMerkleBranch { type Item = &'a mut TapNodeHash; #[inline] - fn into_iter(self) -> Self::IntoIter { - self.0.iter_mut() - } + fn into_iter(self) -> Self::IntoIter { self.0.iter_mut() } } impl core::ops::Deref for TaprootMerkleBranch { type Target = [TapNodeHash]; #[inline] - fn deref(&self) -> &Self::Target { - &self.0 - } + fn deref(&self) -> &Self::Target { &self.0 } } impl core::ops::DerefMut for TaprootMerkleBranch { #[inline] - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } impl AsRef<[TapNodeHash]> for TaprootMerkleBranch { #[inline] - fn as_ref(&self) -> &[TapNodeHash] { - &self.0 - } + fn as_ref(&self) -> &[TapNodeHash] { &self.0 } } impl AsMut<[TapNodeHash]> for TaprootMerkleBranch { #[inline] - fn as_mut(&mut self) -> &mut [TapNodeHash] { - &mut self.0 - } + fn as_mut(&mut self) -> &mut [TapNodeHash] { &mut self.0 } } impl Borrow<[TapNodeHash]> for TaprootMerkleBranch { #[inline] - fn borrow(&self) -> &[TapNodeHash] { - &self.0 - } + fn borrow(&self) -> &[TapNodeHash] { &self.0 } } impl BorrowMut<[TapNodeHash]> for TaprootMerkleBranch { #[inline] - fn borrow_mut(&mut self) -> &mut [TapNodeHash] { - &mut self.0 - } + fn borrow_mut(&mut self) -> &mut [TapNodeHash] { &mut self.0 } } /// Iterator over node hashes within Taproot merkle branch. @@ -247,56 +233,38 @@ pub struct IntoIter(alloc::vec::IntoIter); impl IntoIter { /// Returns the remaining items of this iterator as a slice. #[inline] - pub fn as_slice(&self) -> &[TapNodeHash] { - self.0.as_slice() - } + pub fn as_slice(&self) -> &[TapNodeHash] { self.0.as_slice() } /// Returns the remaining items of this iterator as a mutable slice. #[inline] - pub fn as_mut_slice(&mut self) -> &mut [TapNodeHash] { - self.0.as_mut_slice() - } + pub fn as_mut_slice(&mut self) -> &mut [TapNodeHash] { self.0.as_mut_slice() } } impl Iterator for IntoIter { type Item = TapNodeHash; #[inline] - fn next(&mut self) -> Option { - self.0.next() - } + fn next(&mut self) -> Option { self.0.next() } #[inline] - fn size_hint(&self) -> (usize, Option) { - self.0.size_hint() - } + fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } #[inline] - fn nth(&mut self, n: usize) -> Option { - self.0.nth(n) - } + fn nth(&mut self, n: usize) -> Option { self.0.nth(n) } #[inline] - fn last(self) -> Option { - self.0.last() - } + fn last(self) -> Option { self.0.last() } #[inline] - fn count(self) -> usize { - self.0.count() - } + fn count(self) -> usize { self.0.count() } } impl DoubleEndedIterator for IntoIter { #[inline] - fn next_back(&mut self) -> Option { - self.0.next_back() - } + fn next_back(&mut self) -> Option { self.0.next_back() } #[inline] - fn nth_back(&mut self, n: usize) -> Option { - self.0.nth_back(n) - } + fn nth_back(&mut self, n: usize) -> Option { self.0.nth_back(n) } } impl ExactSizeIterator for IntoIter {} diff --git a/bitcoin/src/taproot/mod.rs b/bitcoin/src/taproot/mod.rs index d51b7111..32271bf2 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -5,8 +5,8 @@ //! This module provides support for taproot tagged hashes. //! -pub mod serialized_signature; pub mod merkle_branch; +pub mod serialized_signature; use core::cmp::Reverse; use core::fmt; diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs index 0137b532..17dddd37 100644 --- a/internals/src/array_vec.rs +++ b/internals/src/array_vec.rs @@ -11,6 +11,7 @@ pub use safety_boundary::ArrayVec; // inside it! mod safety_boundary { use core::mem::MaybeUninit; + use crate::const_tools::cond_const; /// A growable contiguous collection backed by array. @@ -100,83 +101,67 @@ mod safety_boundary { /// memcpy. #[allow(clippy::non_canonical_clone_impl)] impl Clone for ArrayVec { - fn clone(&self) -> Self { - Self::from_slice(self) - } + fn clone(&self) -> Self { Self::from_slice(self) } } - impl core::ops::Deref for ArrayVec { type Target = [T]; - fn deref(&self) -> &Self::Target { - self.as_slice() - } + fn deref(&self) -> &Self::Target { self.as_slice() } } impl core::ops::DerefMut for ArrayVec { - fn deref_mut(&mut self) -> &mut Self::Target { - self.as_mut_slice() - } + fn deref_mut(&mut self) -> &mut Self::Target { self.as_mut_slice() } } impl Eq for ArrayVec {} -impl PartialEq> for ArrayVec { - fn eq(&self, other: &ArrayVec) -> bool { - **self == **other - } +impl PartialEq> + for ArrayVec +{ + fn eq(&self, other: &ArrayVec) -> bool { **self == **other } } impl PartialEq<[T]> for ArrayVec { - fn eq(&self, other: &[T]) -> bool { - **self == *other - } + fn eq(&self, other: &[T]) -> bool { **self == *other } } impl PartialEq> for [T] { - fn eq(&self, other: &ArrayVec) -> bool { - *self == **other - } + fn eq(&self, other: &ArrayVec) -> bool { *self == **other } } -impl PartialEq<[T; LEN]> for ArrayVec { - fn eq(&self, other: &[T; LEN]) -> bool { - **self == *other - } +impl PartialEq<[T; LEN]> + for ArrayVec +{ + fn eq(&self, other: &[T; LEN]) -> bool { **self == *other } } -impl PartialEq> for [T; LEN] { - fn eq(&self, other: &ArrayVec) -> bool { - *self == **other - } +impl PartialEq> + for [T; LEN] +{ + fn eq(&self, other: &ArrayVec) -> bool { *self == **other } } impl Ord for ArrayVec { - fn cmp(&self, other: &ArrayVec) -> core::cmp::Ordering { - (**self).cmp(&**other) - } + fn cmp(&self, other: &ArrayVec) -> core::cmp::Ordering { (**self).cmp(&**other) } } -impl PartialOrd> for ArrayVec { +impl PartialOrd> + for ArrayVec +{ fn partial_cmp(&self, other: &ArrayVec) -> Option { (**self).partial_cmp(&**other) } } impl fmt::Debug for ArrayVec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&**self, f) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } impl core::hash::Hash for ArrayVec { - fn hash(&self, state: &mut H) { - core::hash::Hash::hash(&**self, state) - } + fn hash(&self, state: &mut H) { core::hash::Hash::hash(&**self, state) } } - #[cfg(test)] mod tests { use super::ArrayVec; diff --git a/io/src/lib.rs b/io/src/lib.rs index 4c9beef4..8d234c19 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -23,8 +23,8 @@ extern crate alloc; mod error; mod macros; -use core::convert::TryInto; use core::cmp; +use core::convert::TryInto; #[rustfmt::skip] // Keep public re-exports separate. pub use self::error::{Error, ErrorKind}; diff --git a/units/src/amount.rs b/units/src/amount.rs index 384f11c9..4f304a91 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -940,11 +940,11 @@ impl SignedAmount { pub fn from_str_in(s: &str, denom: Denomination) -> Result { match parse_signed_to_satoshi(s, denom)? { // (negative, amount) - (false, sat) if sat > i64::MAX as u64 => Err(ParseAmountError::TooBig), - (false, sat) => Ok(SignedAmount(sat as i64)), + (false, sat) if sat > i64::MAX as u64 => Err(ParseAmountError::TooBig), + (false, sat) => Ok(SignedAmount(sat as i64)), (true, sat) if sat == i64::MAX as u64 + 1 => Ok(SignedAmount(i64::MIN)), - (true, sat) if sat > i64::MAX as u64 + 1 => Err(ParseAmountError::TooBig), - (true, sat) => Ok(SignedAmount(-(sat as i64))), + (true, sat) if sat > i64::MAX as u64 + 1 => Err(ParseAmountError::TooBig), + (true, sat) => Ok(SignedAmount(-(sat as i64))), } }