From 6cc8b22f82d08184922525b185f259085d78ff9b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 2 Aug 2022 16:00:11 +1000 Subject: [PATCH] Run cargo fmt We have formatting issues on master because we do not yet run the formatter in CI (PR is open). We are about to move the `address` module to `/src` which will require running the formatter. Run `cargo fmt` to fix formatting issues, no other changes. --- src/error.rs | 4 +--- src/lib.rs | 9 +++------ src/parse.rs | 24 +++++++++++------------- src/serde_utils.rs | 3 ++- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/error.rs b/src/error.rs index bc027597..58bbb2d1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -16,9 +16,7 @@ macro_rules! impl_std_error { #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for $type { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(&self.$field) - } + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.$field) } } }; } diff --git a/src/lib.rs b/src/lib.rs index a92c40cd..9a570f70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,24 +61,21 @@ extern crate test; extern crate alloc; // Re-export dependencies we control. -pub use bitcoin_hashes as hashes; -pub use secp256k1; -pub use bech32; -#[cfg(feature="bitcoinconsensus")] +#[cfg(feature = "bitcoinconsensus")] pub use bitcoinconsensus; +pub use {bech32, bitcoin_hashes as hashes, secp256k1}; #[cfg(feature = "serde")] #[macro_use] extern crate actual_serde as serde; - #[cfg(test)] #[macro_use] mod test_macros; mod internal_macros; +mod parse; #[cfg(feature = "serde")] mod serde_utils; -mod parse; #[macro_use] pub mod network; diff --git a/src/parse.rs b/src/parse.rs index 49c09211..3b352d15 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,8 +1,9 @@ -use crate::internal_macros::write_err; -use crate::error::impl_std_error; +use core::convert::TryFrom; use core::fmt; use core::str::FromStr; -use core::convert::TryFrom; + +use crate::error::impl_std_error; +use crate::internal_macros::write_err; use crate::prelude::*; /// Error with rich context returned when a string can't be parsed as an integer. @@ -28,21 +29,15 @@ pub struct ParseIntError { impl ParseIntError { /// Returns the input that was attempted to be parsed. - pub fn input(&self) -> &str { - &self.input - } + pub fn input(&self) -> &str { &self.input } } impl From for core::num::ParseIntError { - fn from(value: ParseIntError) -> Self { - value.source - } + fn from(value: ParseIntError) -> Self { value.source } } impl AsRef for ParseIntError { - fn as_ref(&self) -> &core::num::ParseIntError { - &self.source - } + fn as_ref(&self) -> &core::num::ParseIntError { &self.source } } impl fmt::Display for ParseIntError { @@ -55,7 +50,10 @@ impl fmt::Display for ParseIntError { /// Not strictly neccessary but serves as a lint - avoids weird behavior if someone accidentally /// passes non-integer to the `parse()` function. -pub(crate) trait Integer: FromStr + TryFrom + Sized {} +pub(crate) trait Integer: + FromStr + TryFrom + Sized +{ +} macro_rules! impl_integer { ($($type:ty),* $(,)?) => { diff --git a/src/serde_utils.rs b/src/serde_utils.rs index a25bac7d..3c990b0d 100644 --- a/src/serde_utils.rs +++ b/src/serde_utils.rs @@ -235,9 +235,10 @@ pub mod hex_bytes { //! Module for serialization of byte arrays as hex strings. #![allow(missing_docs)] - use crate::hashes::hex::{FromHex, ToHex}; use serde; + use crate::hashes::hex::{FromHex, ToHex}; + pub fn serialize(bytes: &T, s: S) -> Result where T: serde::Serialize + AsRef<[u8]>,