Merge rust-bitcoin/rust-bitcoin#3180: Automated nightly rustfmt (2024-08-18)

ce3851d241 2024-08-18 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  apoelstra:
    ACK ce3851d241 successfully ran local tests

Tree-SHA512: 17dd4b6de21665b0f99f373d4ce911fbc180df880dcbf9aecbcab24578a0a210a5570faeab1f5e5580ebe63d81310cc8af767ec877ecfa0bf22933e63a0d7834
This commit is contained in:
merge-script 2024-08-18 18:53:44 +00:00
commit 32a42cbfc0
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 35 additions and 96 deletions

View File

@ -12,21 +12,15 @@ impl<T> FromStd<T> {
/// Returns the wrapped value. /// Returns the wrapped value.
#[inline] #[inline]
pub fn into_inner(self) -> T { pub fn into_inner(self) -> T { self.0 }
self.0
}
/// Returns a reference to the wrapped value. /// Returns a reference to the wrapped value.
#[inline] #[inline]
pub fn inner(&self) -> &T { pub fn inner(&self) -> &T { &self.0 }
&self.0
}
/// Returns a mutable reference to the wrapped value. /// Returns a mutable reference to the wrapped value.
#[inline] #[inline]
pub fn inner_mut(&mut self) -> &mut T { pub fn inner_mut(&mut self) -> &mut T { &mut self.0 }
&mut self.0
}
/// Wraps a mutable reference to IO type. /// Wraps a mutable reference to IO type.
#[inline] #[inline]
@ -58,14 +52,10 @@ impl<T: std::io::Read> super::Read for FromStd<T> {
impl<T: std::io::BufRead> super::BufRead for FromStd<T> { impl<T: std::io::BufRead> super::BufRead for FromStd<T> {
#[inline] #[inline]
fn fill_buf(&mut self) -> super::Result<&[u8]> { fn fill_buf(&mut self) -> super::Result<&[u8]> { self.0.fill_buf().map_err(Into::into) }
self.0.fill_buf().map_err(Into::into)
}
#[inline] #[inline]
fn consume(&mut self, amount: usize) { fn consume(&mut self, amount: usize) { self.0.consume(amount) }
self.0.consume(amount)
}
} }
impl<T: std::io::Write> super::Write for FromStd<T> { impl<T: std::io::Write> super::Write for FromStd<T> {
@ -75,9 +65,7 @@ impl<T: std::io::Write> super::Write for FromStd<T> {
} }
#[inline] #[inline]
fn flush(&mut self) -> super::Result<()> { fn flush(&mut self) -> super::Result<()> { self.0.flush().map_err(Into::into) }
self.0.flush().map_err(Into::into)
}
#[inline] #[inline]
fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { fn write_all(&mut self, buf: &[u8]) -> super::Result<()> {
@ -89,43 +77,29 @@ impl<T: std::io::Write> super::Write for FromStd<T> {
impl<T: std::io::Read> std::io::Read for FromStd<T> { impl<T: std::io::Read> std::io::Read for FromStd<T> {
#[inline] #[inline]
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { self.0.read(buf) }
self.0.read(buf)
}
#[inline] #[inline]
fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> { fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> { self.0.read_exact(buf) }
self.0.read_exact(buf)
}
} }
impl<T: std::io::BufRead> std::io::BufRead for FromStd<T> { impl<T: std::io::BufRead> std::io::BufRead for FromStd<T> {
#[inline] #[inline]
fn fill_buf(&mut self) -> std::io::Result<&[u8]> { fn fill_buf(&mut self) -> std::io::Result<&[u8]> { self.0.fill_buf() }
self.0.fill_buf()
}
#[inline] #[inline]
fn consume(&mut self, amount: usize) { fn consume(&mut self, amount: usize) { self.0.consume(amount) }
self.0.consume(amount)
}
} }
impl<T: std::io::Write> std::io::Write for FromStd<T> { impl<T: std::io::Write> std::io::Write for FromStd<T> {
#[inline] #[inline]
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { self.0.write(buf) }
self.0.write(buf)
}
#[inline] #[inline]
fn flush(&mut self) -> std::io::Result<()> { fn flush(&mut self) -> std::io::Result<()> { self.0.flush() }
self.0.flush()
}
#[inline] #[inline]
fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { self.0.write_all(buf) }
self.0.write_all(buf)
}
} }
/// A bridging wrapper providing the std traits for types that already implement our traits. /// A bridging wrapper providing the std traits for types that already implement our traits.
@ -139,21 +113,15 @@ impl<T> ToStd<T> {
/// Returns the wrapped value. /// Returns the wrapped value.
#[inline] #[inline]
pub fn into_inner(self) -> T { pub fn into_inner(self) -> T { self.0 }
self.0
}
/// Returns a reference to the wrapped value. /// Returns a reference to the wrapped value.
#[inline] #[inline]
pub fn inner(&self) -> &T { pub fn inner(&self) -> &T { &self.0 }
&self.0
}
/// Returns a mutable reference to the wrapped value. /// Returns a mutable reference to the wrapped value.
#[inline] #[inline]
pub fn inner_mut(&mut self) -> &mut T { pub fn inner_mut(&mut self) -> &mut T { &mut self.0 }
&mut self.0
}
/// Wraps a mutable reference to IO type. /// Wraps a mutable reference to IO type.
#[inline] #[inline]
@ -185,14 +153,10 @@ impl<T: super::Read> std::io::Read for ToStd<T> {
impl<T: super::BufRead> std::io::BufRead for ToStd<T> { impl<T: super::BufRead> std::io::BufRead for ToStd<T> {
#[inline] #[inline]
fn fill_buf(&mut self) -> std::io::Result<&[u8]> { fn fill_buf(&mut self) -> std::io::Result<&[u8]> { self.0.fill_buf().map_err(Into::into) }
self.0.fill_buf().map_err(Into::into)
}
#[inline] #[inline]
fn consume(&mut self, amount: usize) { fn consume(&mut self, amount: usize) { self.0.consume(amount) }
self.0.consume(amount)
}
} }
impl<T: super::Write> std::io::Write for ToStd<T> { impl<T: super::Write> std::io::Write for ToStd<T> {
@ -202,9 +166,7 @@ impl<T: super::Write> std::io::Write for ToStd<T> {
} }
#[inline] #[inline]
fn flush(&mut self) -> std::io::Result<()> { fn flush(&mut self) -> std::io::Result<()> { self.0.flush().map_err(Into::into) }
self.0.flush().map_err(Into::into)
}
#[inline] #[inline]
fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> {
@ -216,43 +178,29 @@ impl<T: super::Write> std::io::Write for ToStd<T> {
impl<T: super::Read> super::Read for ToStd<T> { impl<T: super::Read> super::Read for ToStd<T> {
#[inline] #[inline]
fn read(&mut self, buf: &mut [u8]) -> super::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> super::Result<usize> { self.0.read(buf) }
self.0.read(buf)
}
#[inline] #[inline]
fn read_exact(&mut self, buf: &mut [u8]) -> super::Result<()> { fn read_exact(&mut self, buf: &mut [u8]) -> super::Result<()> { self.0.read_exact(buf) }
self.0.read_exact(buf)
}
} }
impl<T: super::BufRead> super::BufRead for ToStd<T> { impl<T: super::BufRead> super::BufRead for ToStd<T> {
#[inline] #[inline]
fn fill_buf(&mut self) -> super::Result<&[u8]> { fn fill_buf(&mut self) -> super::Result<&[u8]> { self.0.fill_buf() }
self.0.fill_buf()
}
#[inline] #[inline]
fn consume(&mut self, amount: usize) { fn consume(&mut self, amount: usize) { self.0.consume(amount) }
self.0.consume(amount)
}
} }
impl<T: super::Write> super::Write for ToStd<T> { impl<T: super::Write> super::Write for ToStd<T> {
#[inline] #[inline]
fn write(&mut self, buf: &[u8]) -> super::Result<usize> { fn write(&mut self, buf: &[u8]) -> super::Result<usize> { self.0.write(buf) }
self.0.write(buf)
}
#[inline] #[inline]
fn flush(&mut self) -> super::Result<()> { fn flush(&mut self) -> super::Result<()> { self.0.flush() }
self.0.flush()
}
#[inline] #[inline]
fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { fn write_all(&mut self, buf: &[u8]) -> super::Result<()> { self.0.write_all(buf) }
self.0.write_all(buf)
}
} }
macro_rules! impl_our { macro_rules! impl_our {

View File

@ -21,18 +21,18 @@
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
extern crate alloc; extern crate alloc;
mod error;
mod macros;
#[cfg(feature = "std")] #[cfg(feature = "std")]
mod bridge; mod bridge;
mod error;
#[cfg(feature = "std")] mod macros;
pub use bridge::{FromStd, ToStd};
#[cfg(all(not(feature = "std"), feature = "alloc"))] #[cfg(all(not(feature = "std"), feature = "alloc"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::cmp; use core::cmp;
#[cfg(feature = "std")]
pub use bridge::{FromStd, ToStd};
#[rustfmt::skip] // Keep public re-exports separate. #[rustfmt::skip] // Keep public re-exports separate.
pub use self::error::{Error, ErrorKind}; pub use self::error::{Error, ErrorKind};
@ -194,9 +194,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
/// Note that setting a position that is larger than the buffer length will cause reads to /// Note that setting a position that is larger than the buffer length will cause reads to
/// return no bytes (EOF). /// return no bytes (EOF).
#[inline] #[inline]
pub fn set_position(&mut self, position: u64) { pub fn set_position(&mut self, position: u64) { self.pos = position; }
self.pos = position;
}
/// Returns the inner buffer. /// Returns the inner buffer.
/// ///
@ -311,18 +309,14 @@ pub fn sink() -> Sink { Sink }
/// All methods are passed through converting the errors. /// All methods are passed through converting the errors.
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[inline] #[inline]
pub const fn from_std<T>(std_io: T) -> FromStd<T> { pub const fn from_std<T>(std_io: T) -> FromStd<T> { FromStd::new(std_io) }
FromStd::new(std_io)
}
/// Wraps a mutable reference to `std` IO type to implement the traits from this crate. /// Wraps a mutable reference to `std` IO type to implement the traits from this crate.
/// ///
/// All methods are passed through converting the errors. /// All methods are passed through converting the errors.
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[inline] #[inline]
pub fn from_std_mut<T>(std_io: &mut T) -> &mut FromStd<T> { pub fn from_std_mut<T>(std_io: &mut T) -> &mut FromStd<T> { FromStd::new_mut(std_io) }
FromStd::new_mut(std_io)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -41,10 +41,7 @@ pub use units::*;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
pub use self::locktime::{absolute, relative}; pub use self::locktime::{absolute, relative};
#[doc(inline)] #[doc(inline)]
pub use self::{ pub use self::{pow::CompactTarget, sequence::Sequence};
pow::CompactTarget,
sequence::Sequence,
};
#[rustfmt::skip] #[rustfmt::skip]
#[allow(unused_imports)] #[allow(unused_imports)]