From 1c89e07537cf26e3a81f8030d4a91009574a6777 Mon Sep 17 00:00:00 2001 From: apoelstra Date: Sun, 26 Nov 2023 00:57:53 +0000 Subject: [PATCH] 2023-11-26 automated rustfmt nightly --- io/src/lib.rs | 50 +++++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/io/src/lib.rs b/io/src/lib.rs index b21acc8a..4c663061 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -15,7 +15,6 @@ // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] - #![cfg_attr(not(feature = "std"), no_std)] #[cfg(any(feature = "alloc", feature = "std"))] @@ -24,10 +23,10 @@ extern crate alloc; /// Standard I/O stream definitions which are API-equivalent to `std`'s `io` module. See /// [`std::io`] for more info. pub mod io { - use core::convert::TryInto; - use core::fmt::{Debug, Display, Formatter}; #[cfg(any(feature = "alloc", feature = "std"))] use alloc::boxed::Box; + use core::convert::TryInto; + use core::fmt::{Debug, Display, Formatter}; #[cfg(all(feature = "alloc", not(feature = "std")))] mod sealed { @@ -38,14 +37,10 @@ pub mod io { fn into(self) -> Box; } impl IntoBoxDynDebug for &str { - fn into(self) -> Box { - Box::new(String::from(self)) - } + fn into(self) -> Box { Box::new(String::from(self)) } } impl IntoBoxDynDebug for String { - fn into(self) -> Box { - Box::new(self) - } + fn into(self) -> Box { Box::new(self) } } } @@ -71,9 +66,7 @@ pub mod io { Self { kind, error: Some(error.into()) } } - pub fn kind(&self) -> ErrorKind { - self.kind - } + pub fn kind(&self) -> ErrorKind { self.kind } } impl From for Error { @@ -219,9 +212,7 @@ pub mod io { Ok(()) } #[inline] - fn take(&mut self, limit: u64) -> Take { - Take { reader: self, remaining: limit } - } + fn take(&mut self, limit: u64) -> Take { Take { reader: self, remaining: limit } } } pub struct Take<'a, R: Read + ?Sized> { @@ -263,17 +254,11 @@ pub mod io { } impl> Cursor { #[inline] - pub fn new(inner: T) -> Self { - Cursor { inner, pos: 0 } - } + pub fn new(inner: T) -> Self { Cursor { inner, pos: 0 } } #[inline] - pub fn position(&self) -> u64 { - self.pos - } + pub fn position(&self) -> u64 { self.pos } #[inline] - pub fn into_inner(self) -> T { - self.inner - } + pub fn into_inner(self) -> T { self.inner } } impl> Read for Cursor { #[inline] @@ -282,7 +267,9 @@ pub mod io { let start_pos = self.pos.try_into().unwrap_or(inner.len()); let read = core::cmp::min(inner.len().saturating_sub(start_pos), buf.len()); buf[..read].copy_from_slice(&inner[start_pos..start_pos + read]); - self.pos = self.pos.saturating_add(read.try_into().unwrap_or(u64::max_value() /* unreachable */)); + self.pos = self + .pos + .saturating_add(read.try_into().unwrap_or(u64::max_value() /* unreachable */)); Ok(read) } } @@ -313,9 +300,7 @@ pub mod io { Ok(::write(self, buf)?) } #[inline] - fn flush(&mut self) -> Result<()> { - Ok(::flush(self)?) - } + fn flush(&mut self) -> Result<()> { Ok(::flush(self)?) } } #[cfg(all(feature = "alloc", not(feature = "std")))] @@ -347,9 +332,7 @@ pub mod io { #[cfg(not(feature = "std"))] impl Write for Sink { #[inline] - fn write(&mut self, buf: &[u8]) -> Result { - Ok(buf.len()) - } + fn write(&mut self, buf: &[u8]) -> Result { Ok(buf.len()) } #[inline] fn write_all(&mut self, _: &[u8]) -> Result<()> { Ok(()) } #[inline] @@ -358,9 +341,7 @@ pub mod io { #[cfg(feature = "std")] impl std::io::Write for Sink { #[inline] - fn write(&mut self, buf: &[u8]) -> std::io::Result { - Ok(buf.len()) - } + fn write(&mut self, buf: &[u8]) -> std::io::Result { Ok(buf.len()) } #[inline] fn write_all(&mut self, _: &[u8]) -> std::io::Result<()> { Ok(()) } #[inline] @@ -399,7 +380,6 @@ macro_rules! impl_write { } } - #[macro_export] /// Because we cannot provide a blanket implementation of [`std::io::Write`] for all implementers /// of this crate's `io::Write` trait, we provide this macro instead.