From 19acae716334ce2b215e4baf1cf405d05b326a9a Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 22 Dec 2024 01:21:54 +0000 Subject: [PATCH] 2024-12-22 automated rustfmt nightly --- internals/src/array_vec.rs | 4 ++-- units/src/amount/tests.rs | 6 ++---- units/src/amount/verification.rs | 2 +- units/src/internal_macros.rs | 12 ++++++------ units/tests/api.rs | 8 +++----- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs index 24003e14b..bd4954aac 100644 --- a/internals/src/array_vec.rs +++ b/internals/src/array_vec.rs @@ -193,7 +193,7 @@ mod tests { mod verification { use super::*; - #[kani::unwind(16)] // One greater than 15 (max number of elements). + #[kani::unwind(16)] // One greater than 15 (max number of elements). #[kani::proof] fn no_out_of_bounds_less_than_cap() { const CAP: usize = 32; @@ -212,7 +212,7 @@ mod verification { } } - #[kani::unwind(16)] // One grater than 15. + #[kani::unwind(16)] // One grater than 15. #[kani::proof] fn no_out_of_bounds_upto_cap() { const CAP: usize = 15; diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index c4f6ea9fc..d5e939477 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -907,13 +907,11 @@ fn checked_sum_amounts() { let sum = amounts.into_iter().checked_sum(); assert_eq!(None, sum); - let amounts = - [SignedAmount::MIN, SignedAmount::from_sat(-1), SignedAmount::from_sat(21)]; + let amounts = [SignedAmount::MIN, SignedAmount::from_sat(-1), SignedAmount::from_sat(21)]; let sum = amounts.into_iter().checked_sum(); assert_eq!(None, sum); - let amounts = - [SignedAmount::MAX, SignedAmount::from_sat(1), SignedAmount::from_sat(21)]; + let amounts = [SignedAmount::MAX, SignedAmount::from_sat(1), SignedAmount::from_sat(21)]; let sum = amounts.into_iter().checked_sum(); assert_eq!(None, sum); diff --git a/units/src/amount/verification.rs b/units/src/amount/verification.rs index ae970e186..f0d7b47eb 100644 --- a/units/src/amount/verification.rs +++ b/units/src/amount/verification.rs @@ -25,7 +25,7 @@ fn u_amount_homomorphic() { let n2 = kani::any::(); // Assume we don't overflow in the actual tests. kani::assume(n1.checked_add(n2).is_some()); // Adding u64s doesn't overflow. - let a1 = Amount::from_sat(n1); // TODO: If from_sat enforces invariant assume this `is_ok()`. + let a1 = Amount::from_sat(n1); // TODO: If from_sat enforces invariant assume this `is_ok()`. let a2 = Amount::from_sat(n2); kani::assume(a1.checked_add(a2).is_some()); // Adding amounts doesn't overflow. diff --git a/units/src/internal_macros.rs b/units/src/internal_macros.rs index 03536b5ec..475f9374e 100644 --- a/units/src/internal_macros.rs +++ b/units/src/internal_macros.rs @@ -30,21 +30,21 @@ macro_rules! impl_add_for_references { fn add(self, rhs: &'a $ty) -> Self::Output { *self + *rhs } } - } + }; } pub(crate) use impl_add_for_references; /// Implement `ops::AddAssign` for `$ty` and `&$ty`. macro_rules! impl_add_assign { ($ty:ident) => { - impl core::ops::AddAssign<$ty> for $ty { + impl core::ops::AddAssign<$ty> for $ty { fn add_assign(&mut self, rhs: $ty) { *self = *self + rhs } } impl core::ops::AddAssign<&$ty> for $ty { fn add_assign(&mut self, rhs: &$ty) { *self = *self + *rhs } } - } + }; } pub(crate) use impl_add_assign; @@ -74,20 +74,20 @@ macro_rules! impl_sub_for_references { fn sub(self, rhs: &'a $ty) -> Self::Output { *self - *rhs } } - } + }; } pub(crate) use impl_sub_for_references; /// Implement `ops::SubAssign` for `$ty` and `&$ty`. macro_rules! impl_sub_assign { ($ty:ident) => { - impl core::ops::SubAssign<$ty> for $ty { + impl core::ops::SubAssign<$ty> for $ty { fn sub_assign(&mut self, rhs: $ty) { *self = *self - rhs } } impl core::ops::SubAssign<&$ty> for $ty { fn sub_assign(&mut self, rhs: &$ty) { *self = *self - *rhs } } - } + }; } pub(crate) use impl_sub_assign; diff --git a/units/tests/api.rs b/units/tests/api.rs index 44eee3d9c..73d6fcf26 100644 --- a/units/tests/api.rs +++ b/units/tests/api.rs @@ -20,13 +20,13 @@ #![allow(unused_imports)] // These imports test "typical" usage by user code. +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; use bitcoin_units::locktime::{absolute, relative}; // Typical usage is `absolute::Height`. use bitcoin_units::{ amount, block, fee_rate, locktime, parse, weight, Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight, }; -#[cfg(feature = "arbitrary")] -use arbitrary::{Arbitrary, Unstructured}; /// A struct that includes all public non-error enums. #[derive(Debug)] // All public types implement Debug (C-DEBUG). @@ -298,9 +298,7 @@ impl<'a> Arbitrary<'a> for Structs { #[cfg(feature = "arbitrary")] impl<'a> Arbitrary<'a> for Enums { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - let a = Enums { - a: amount::Denomination::arbitrary(u)?, - }; + let a = Enums { a: amount::Denomination::arbitrary(u)? }; Ok(a) } }