diff --git a/io/src/bridge.rs b/io/src/bridge.rs index 85e999167..2a74974ce 100644 --- a/io/src/bridge.rs +++ b/io/src/bridge.rs @@ -12,21 +12,15 @@ impl FromStd { /// Returns the wrapped value. #[inline] - pub fn into_inner(self) -> T { - self.0 - } + pub fn into_inner(self) -> T { self.0 } /// Returns a reference to the wrapped value. #[inline] - pub fn inner(&self) -> &T { - &self.0 - } + pub fn inner(&self) -> &T { &self.0 } /// Returns a mutable reference to the wrapped value. #[inline] - pub fn inner_mut(&mut self) -> &mut T { - &mut self.0 - } + pub fn inner_mut(&mut self) -> &mut T { &mut self.0 } /// Wraps a mutable reference to IO type. #[inline] @@ -58,14 +52,10 @@ impl super::Read for FromStd { impl super::BufRead for FromStd { #[inline] - fn fill_buf(&mut self) -> super::Result<&[u8]> { - self.0.fill_buf().map_err(Into::into) - } + fn fill_buf(&mut self) -> super::Result<&[u8]> { self.0.fill_buf().map_err(Into::into) } #[inline] - fn consume(&mut self, amount: usize) { - self.0.consume(amount) - } + fn consume(&mut self, amount: usize) { self.0.consume(amount) } } impl super::Write for FromStd { @@ -75,9 +65,7 @@ impl super::Write for FromStd { } #[inline] - fn flush(&mut self) -> super::Result<()> { - self.0.flush().map_err(Into::into) - } + fn flush(&mut self) -> super::Result<()> { self.0.flush().map_err(Into::into) } #[inline] fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { @@ -89,43 +77,29 @@ impl super::Write for FromStd { impl std::io::Read for FromStd { #[inline] - fn read(&mut self, buf: &mut [u8]) -> std::io::Result { - self.0.read(buf) - } + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { self.0.read(buf) } #[inline] - fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> { - self.0.read_exact(buf) - } + fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> { self.0.read_exact(buf) } } impl std::io::BufRead for FromStd { #[inline] - fn fill_buf(&mut self) -> std::io::Result<&[u8]> { - self.0.fill_buf() - } + fn fill_buf(&mut self) -> std::io::Result<&[u8]> { self.0.fill_buf() } #[inline] - fn consume(&mut self, amount: usize) { - self.0.consume(amount) - } + fn consume(&mut self, amount: usize) { self.0.consume(amount) } } impl std::io::Write for FromStd { #[inline] - fn write(&mut self, buf: &[u8]) -> std::io::Result { - self.0.write(buf) - } + fn write(&mut self, buf: &[u8]) -> std::io::Result { self.0.write(buf) } #[inline] - fn flush(&mut self) -> std::io::Result<()> { - self.0.flush() - } + fn flush(&mut self) -> std::io::Result<()> { self.0.flush() } #[inline] - fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { - self.0.write_all(buf) - } + fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { self.0.write_all(buf) } } /// A bridging wrapper providing the std traits for types that already implement our traits. @@ -139,21 +113,15 @@ impl ToStd { /// Returns the wrapped value. #[inline] - pub fn into_inner(self) -> T { - self.0 - } + pub fn into_inner(self) -> T { self.0 } /// Returns a reference to the wrapped value. #[inline] - pub fn inner(&self) -> &T { - &self.0 - } + pub fn inner(&self) -> &T { &self.0 } /// Returns a mutable reference to the wrapped value. #[inline] - pub fn inner_mut(&mut self) -> &mut T { - &mut self.0 - } + pub fn inner_mut(&mut self) -> &mut T { &mut self.0 } /// Wraps a mutable reference to IO type. #[inline] @@ -185,14 +153,10 @@ impl std::io::Read for ToStd { impl std::io::BufRead for ToStd { #[inline] - fn fill_buf(&mut self) -> std::io::Result<&[u8]> { - self.0.fill_buf().map_err(Into::into) - } + fn fill_buf(&mut self) -> std::io::Result<&[u8]> { self.0.fill_buf().map_err(Into::into) } #[inline] - fn consume(&mut self, amount: usize) { - self.0.consume(amount) - } + fn consume(&mut self, amount: usize) { self.0.consume(amount) } } impl std::io::Write for ToStd { @@ -202,9 +166,7 @@ impl std::io::Write for ToStd { } #[inline] - fn flush(&mut self) -> std::io::Result<()> { - self.0.flush().map_err(Into::into) - } + fn flush(&mut self) -> std::io::Result<()> { self.0.flush().map_err(Into::into) } #[inline] fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { @@ -216,43 +178,29 @@ impl std::io::Write for ToStd { impl super::Read for ToStd { #[inline] - fn read(&mut self, buf: &mut [u8]) -> super::Result { - self.0.read(buf) - } + fn read(&mut self, buf: &mut [u8]) -> super::Result { self.0.read(buf) } #[inline] - fn read_exact(&mut self, buf: &mut [u8]) -> super::Result<()> { - self.0.read_exact(buf) - } + fn read_exact(&mut self, buf: &mut [u8]) -> super::Result<()> { self.0.read_exact(buf) } } impl super::BufRead for ToStd { #[inline] - fn fill_buf(&mut self) -> super::Result<&[u8]> { - self.0.fill_buf() - } + fn fill_buf(&mut self) -> super::Result<&[u8]> { self.0.fill_buf() } #[inline] - fn consume(&mut self, amount: usize) { - self.0.consume(amount) - } + fn consume(&mut self, amount: usize) { self.0.consume(amount) } } impl super::Write for ToStd { #[inline] - fn write(&mut self, buf: &[u8]) -> super::Result { - self.0.write(buf) - } + fn write(&mut self, buf: &[u8]) -> super::Result { self.0.write(buf) } #[inline] - fn flush(&mut self) -> super::Result<()> { - self.0.flush() - } + fn flush(&mut self) -> super::Result<()> { self.0.flush() } #[inline] - fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { - self.0.write_all(buf) - } + fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { self.0.write_all(buf) } } macro_rules! impl_our { diff --git a/io/src/lib.rs b/io/src/lib.rs index 1fc5dd53e..7d0dd396b 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -21,18 +21,18 @@ #[cfg(feature = "alloc")] extern crate alloc; -mod error; -mod macros; #[cfg(feature = "std")] mod bridge; - -#[cfg(feature = "std")] -pub use bridge::{FromStd, ToStd}; +mod error; +mod macros; #[cfg(all(not(feature = "std"), feature = "alloc"))] use alloc::vec::Vec; use core::cmp; +#[cfg(feature = "std")] +pub use bridge::{FromStd, ToStd}; + #[rustfmt::skip] // Keep public re-exports separate. pub use self::error::{Error, ErrorKind}; @@ -194,9 +194,7 @@ impl> Cursor { /// Note that setting a position that is larger than the buffer length will cause reads to /// return no bytes (EOF). #[inline] - pub fn set_position(&mut self, position: u64) { - self.pos = position; - } + pub fn set_position(&mut self, position: u64) { self.pos = position; } /// Returns the inner buffer. /// @@ -311,18 +309,14 @@ pub fn sink() -> Sink { Sink } /// All methods are passed through converting the errors. #[cfg(feature = "std")] #[inline] -pub const fn from_std(std_io: T) -> FromStd { - FromStd::new(std_io) -} +pub const fn from_std(std_io: T) -> FromStd { FromStd::new(std_io) } /// Wraps a mutable reference to `std` IO type to implement the traits from this crate. /// /// All methods are passed through converting the errors. #[cfg(feature = "std")] #[inline] -pub fn from_std_mut(std_io: &mut T) -> &mut FromStd { - FromStd::new_mut(std_io) -} +pub fn from_std_mut(std_io: &mut T) -> &mut FromStd { FromStd::new_mut(std_io) } #[cfg(test)] mod tests { diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 78838eaf5..3b90a8507 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -41,10 +41,7 @@ pub use units::*; #[cfg(feature = "alloc")] pub use self::locktime::{absolute, relative}; #[doc(inline)] -pub use self::{ - pow::CompactTarget, - sequence::Sequence, -}; +pub use self::{pow::CompactTarget, sequence::Sequence}; #[rustfmt::skip] #[allow(unused_imports)]