2024-12-15 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2024-12-15 01:35:28 +00:00 committed by github-actions[bot]
parent 1c4d66ab39
commit 18d904d647
4 changed files with 12 additions and 14 deletions

View File

@ -398,9 +398,7 @@ mod tests {
pub amount: Amount, pub amount: Amount,
} }
let orig = HasAmount { let orig = HasAmount { amount: Amount::ONE_BTC };
amount: Amount::ONE_BTC,
};
let json = serde_json::to_string(&orig).expect("failed to ser"); let json = serde_json::to_string(&orig).expect("failed to ser");
let want = "{\"amount\":100000000}"; let want = "{\"amount\":100000000}";
@ -419,9 +417,7 @@ mod tests {
pub amount: Amount, pub amount: Amount,
} }
let orig = HasAmount { let orig = HasAmount { amount: Amount::ONE_BTC };
amount: Amount::ONE_BTC,
};
let json = serde_json::to_string(&orig).expect("failed to ser"); let json = serde_json::to_string(&orig).expect("failed to ser");
let want = "{\"amount\":1.0}"; let want = "{\"amount\":1.0}";
@ -440,9 +436,7 @@ mod tests {
pub amount: Amount, pub amount: Amount,
} }
let orig = HasAmount { let orig = HasAmount { amount: Amount::ONE_BTC };
amount: Amount::ONE_BTC,
};
let json = serde_json::to_string(&orig).expect("failed to ser"); let json = serde_json::to_string(&orig).expect("failed to ser");
let want = "{\"amount\":\"1\"}"; let want = "{\"amount\":\"1\"}";

View File

@ -112,9 +112,9 @@ impl SignedAmount {
ParseAmountErrorInner::OutOfRange(OutOfRangeError::too_big(true)), ParseAmountErrorInner::OutOfRange(OutOfRangeError::too_big(true)),
)), )),
(false, sat) => Ok(SignedAmount(sat as i64)), (false, sat) => Ok(SignedAmount(sat as i64)),
(true, sat) if sat > SignedAmount::MIN.to_sat().unsigned_abs() => Err(ParseAmountError( (true, sat) if sat > SignedAmount::MIN.to_sat().unsigned_abs() => Err(
ParseAmountErrorInner::OutOfRange(OutOfRangeError::too_small()), ParseAmountError(ParseAmountErrorInner::OutOfRange(OutOfRangeError::too_small())),
)), ),
(true, sat) => Ok(SignedAmount(-(sat as i64))), (true, sat) => Ok(SignedAmount(-(sat as i64))),
} }
} }

View File

@ -619,7 +619,8 @@ fn to_from_string_in() {
ua_str(&ua_sat(1_000_000_000_000).to_string_in(D::MilliBitcoin), D::MilliBitcoin), ua_str(&ua_sat(1_000_000_000_000).to_string_in(D::MilliBitcoin), D::MilliBitcoin),
Ok(ua_sat(1_000_000_000_000)) Ok(ua_sat(1_000_000_000_000))
); );
assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::MilliBitcoin), D::MilliBitcoin).is_ok()); assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::MilliBitcoin), D::MilliBitcoin)
.is_ok());
assert_eq!(sa_str(&sa_sat(-1).to_string_in(D::MicroBitcoin), D::MicroBitcoin), Ok(sa_sat(-1))); assert_eq!(sa_str(&sa_sat(-1).to_string_in(D::MicroBitcoin), D::MicroBitcoin), Ok(sa_sat(-1)));

View File

@ -52,7 +52,10 @@ impl AsRef<core::num::ParseIntError> for ParseIntError {
/// Not strictly necessary but serves as a lint - avoids weird behavior if someone accidentally /// Not strictly necessary but serves as a lint - avoids weird behavior if someone accidentally
/// passes non-integer to the `parse()` function. /// passes non-integer to the `parse()` function.
pub trait Integer: FromStr<Err = core::num::ParseIntError> + TryFrom<i8> + Sized + sealed::Sealed {} pub trait Integer:
FromStr<Err = core::num::ParseIntError> + TryFrom<i8> + Sized + sealed::Sealed
{
}
macro_rules! impl_integer { macro_rules! impl_integer {
($($type:ty),* $(,)?) => { ($($type:ty),* $(,)?) => {