2025-04-27 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2025-04-27 01:36:56 +00:00 committed by github-actions[bot]
parent 1bee39bfe7
commit 6737c3a0e5
10 changed files with 17 additions and 18 deletions

View File

@ -251,6 +251,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use alloc::vec; use alloc::vec;
use hex::FromHex as _; use hex::FromHex as _;
use super::*; use super::*;

View File

@ -224,13 +224,11 @@ mod tests {
let arbitrary_bytes = [0x00; 32]; let arbitrary_bytes = [0x00; 32];
assert!(WitnessProgram::new(WitnessVersion::V1, &arbitrary_bytes) assert!(WitnessProgram::new(WitnessVersion::V1, &arbitrary_bytes)
.expect("valid witness program") .expect("valid witness program")
.is_p2tr() .is_p2tr());
);
let p2a_bytes = [78, 115]; let p2a_bytes = [78, 115];
assert!(WitnessProgram::new(WitnessVersion::V1, &p2a_bytes) assert!(WitnessProgram::new(WitnessVersion::V1, &p2a_bytes)
.expect("valid witness program") .expect("valid witness program")
.is_p2a() .is_p2a());
);
} }
} }

View File

@ -361,7 +361,8 @@ mod test {
#[test] #[test]
fn consensus_serialize() { fn consensus_serialize() {
let el_0 = hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105").to_vec(); let el_0 =
hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105").to_vec();
let el_1 = hex!("000000").to_vec(); let el_1 = hex!("000000").to_vec();
let mut want_witness = Witness::default(); let mut want_witness = Witness::default();

View File

@ -512,6 +512,8 @@ impl std::error::Error for MerkleBlockError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use hex::{DisplayHex, FromHex};
use hex_lit::hex;
#[cfg(feature = "rand-std")] #[cfg(feature = "rand-std")]
use {core::cmp, secp256k1::rand::prelude::*}; use {core::cmp, secp256k1::rand::prelude::*};
@ -519,8 +521,6 @@ mod tests {
use crate::block::{BlockUncheckedExt as _, Unchecked}; use crate::block::{BlockUncheckedExt as _, Unchecked};
use crate::consensus::encode; use crate::consensus::encode;
use crate::hash_types::Txid; use crate::hash_types::Txid;
use hex::{DisplayHex, FromHex};
use hex_lit::hex;
#[cfg(feature = "rand-std")] #[cfg(feature = "rand-std")]
macro_rules! pmt_tests { macro_rules! pmt_tests {

View File

@ -789,7 +789,9 @@ impl TryFrom<TaprootBuilder> for TapTree {
/// ///
/// A [`TapTree`] iff the `builder` is complete, otherwise return [`IncompleteBuilderError`] /// A [`TapTree`] iff the `builder` is complete, otherwise return [`IncompleteBuilderError`]
/// error with the content of incomplete `builder` instance. /// error with the content of incomplete `builder` instance.
fn try_from(builder: TaprootBuilder) -> Result<Self, Self::Error> { builder.try_into_tap_tree() } fn try_from(builder: TaprootBuilder) -> Result<Self, Self::Error> {
builder.try_into_tap_tree()
}
} }
impl TryFrom<NodeInfo> for TapTree { impl TryFrom<NodeInfo> for TapTree {

View File

@ -223,7 +223,8 @@ impl fmt::Display for Header {
self.time.to_u32().to_le_bytes().as_hex(), self.time.to_u32().to_le_bytes().as_hex(),
self.bits.to_consensus().to_le_bytes().as_hex(), self.bits.to_consensus().to_le_bytes().as_hex(),
self.nonce.to_le_bytes().as_hex(), self.nonce.to_le_bytes().as_hex(),
).expect("total length of written objects is 160 characters"); )
.expect("total length of written objects is 160 characters");
fmt::Display::fmt(&buf, f) fmt::Display::fmt(&buf, f)
} }
} }

View File

@ -901,7 +901,7 @@ mod test {
let witness4: Witness = empty_data.iter().collect(); let witness4: Witness = empty_data.iter().collect();
assert!(witness4.is_empty()); assert!(witness4.is_empty());
} }
#[cfg(feature = "hex")] #[cfg(feature = "hex")]
#[test] #[test]
fn test_from_hex() { fn test_from_hex() {

View File

@ -7,8 +7,8 @@ use core::ops;
use NumOpResult as R; use NumOpResult as R;
use super::{Amount, SignedAmount}; use super::{Amount, SignedAmount};
use crate::internal_macros::{impl_div_assign, impl_mul_assign};
use crate::{MathOp, NumOpError, NumOpResult, OptionExt}; use crate::{MathOp, NumOpError, NumOpResult, OptionExt};
use crate::internal_macros::{impl_mul_assign, impl_div_assign};
impl From<Amount> for NumOpResult<Amount> { impl From<Amount> for NumOpResult<Amount> {
fn from(a: Amount) -> Self { Self::Valid(a) } fn from(a: Amount) -> Self { Self::Valid(a) }

View File

@ -24,14 +24,10 @@ fn sat(sat: u64) -> Amount { Amount::from_sat(sat).unwrap() }
fn ssat(ssat: i64) -> SignedAmount { SignedAmount::from_sat(ssat).unwrap() } fn ssat(ssat: i64) -> SignedAmount { SignedAmount::from_sat(ssat).unwrap() }
#[track_caller] #[track_caller]
fn res(n_sat: u64) -> NumOpResult<Amount>{ fn res(n_sat: u64) -> NumOpResult<Amount> { NumOpResult::from(sat(n_sat)) }
NumOpResult::from(sat(n_sat))
}
#[track_caller] #[track_caller]
fn sres(n_sat: i64) -> NumOpResult<SignedAmount>{ fn sres(n_sat: i64) -> NumOpResult<SignedAmount> { NumOpResult::from(ssat(n_sat)) }
NumOpResult::from(ssat(n_sat))
}
#[test] #[test]
fn sanity_check() { fn sanity_check() {

View File

@ -2,8 +2,8 @@
//! Provides a monodic type returned by mathematical operations (`core::ops`). //! Provides a monodic type returned by mathematical operations (`core::ops`).
use core::fmt;
use core::convert::Infallible; use core::convert::Infallible;
use core::fmt;
use NumOpResult as R; use NumOpResult as R;