Merge rust-bitcoin/rust-bitcoin#3911: Make `Cursor` methods const

9ef8e294ac api: Run just check-api (Tobin C. Harding)
3542803c4e Make Cursor methods const (Tobin C. Harding)

Pull request description:

  Mirror the `std::io::Cursor` type by making the same methods `const`.

ACKs for top commit:
  jamillambert:
    ACK 9ef8e294ac
  apoelstra:
    ACK 9ef8e294ac81c79f413fbe47372a3f94c926ef12; successfully ran local tests

Tree-SHA512: 60ad8169c9bcc90360fcd3c3439256d86af4a77733a00a66e9b155bdb89580d4971efd55a93f1873363ed9d24f0b2b8f5a0da1857bb5aa8a112b13e27239a984
This commit is contained in:
merge-script 2025-01-16 19:47:47 +00:00
commit dc76043dcf
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
4 changed files with 12 additions and 12 deletions

View File

@ -164,6 +164,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock pub bitcoin_io::ErrorKind::WouldBlock
pub bitcoin_io::ErrorKind::WriteZero pub bitcoin_io::ErrorKind::WriteZero
pub const fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub const fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub const fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub const fn bitcoin_io::FromStd<T>::new(inner: T) -> Self pub const fn bitcoin_io::FromStd<T>::new(inner: T) -> Self
pub const fn bitcoin_io::ToStd<T>::new(inner: T) -> Self pub const fn bitcoin_io::ToStd<T>::new(inner: T) -> Self
pub const fn bitcoin_io::from_std<T>(std_io: T) -> bitcoin_io::FromStd<T> pub const fn bitcoin_io::from_std<T>(std_io: T) -> bitcoin_io::FromStd<T>
@ -232,11 +235,8 @@ pub fn bitcoin_io::Cursor<T>::eq(&self, other: &bitcoin_io::Cursor<T>) -> bool
pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize> pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize>
pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64) pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::cause(&self) -> core::option::Option<&dyn core::error::Error> pub fn bitcoin_io::Error::cause(&self) -> core::option::Option<&dyn core::error::Error>

View File

@ -83,6 +83,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock pub bitcoin_io::ErrorKind::WouldBlock
pub bitcoin_io::ErrorKind::WriteZero pub bitcoin_io::ErrorKind::WriteZero
pub const fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub const fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub const fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub enum bitcoin_io::ErrorKind pub enum bitcoin_io::ErrorKind
pub fn &[u8]::consume(&mut self, amount: usize) pub fn &[u8]::consume(&mut self, amount: usize)
pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
@ -107,11 +110,8 @@ pub fn bitcoin_io::Cursor<T>::eq(&self, other: &bitcoin_io::Cursor<T>) -> bool
pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize> pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize>
pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64) pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

View File

@ -81,6 +81,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock pub bitcoin_io::ErrorKind::WouldBlock
pub bitcoin_io::ErrorKind::WriteZero pub bitcoin_io::ErrorKind::WriteZero
pub const fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub const fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub const fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub enum bitcoin_io::ErrorKind pub enum bitcoin_io::ErrorKind
pub fn &[u8]::consume(&mut self, amount: usize) pub fn &[u8]::consume(&mut self, amount: usize)
pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
@ -103,11 +106,8 @@ pub fn bitcoin_io::Cursor<T>::eq(&self, other: &bitcoin_io::Cursor<T>) -> bool
pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]> pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Cursor<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
pub fn bitcoin_io::Cursor<T>::position(&self) -> u64
pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize> pub fn bitcoin_io::Cursor<T>::read(&mut self, buf: &mut [u8]) -> bitcoin_io::Result<usize>
pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64) pub fn bitcoin_io::Cursor<T>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

View File

@ -201,11 +201,11 @@ pub struct Cursor<T> {
impl<T: AsRef<[u8]>> Cursor<T> { impl<T: AsRef<[u8]>> Cursor<T> {
/// Constructs a new `Cursor` by wrapping `inner`. /// Constructs a new `Cursor` by wrapping `inner`.
#[inline] #[inline]
pub fn new(inner: T) -> Self { Cursor { inner, pos: 0 } } pub const fn new(inner: T) -> Self { Cursor { inner, pos: 0 } }
/// Returns the position read up to thus far. /// Returns the position read up to thus far.
#[inline] #[inline]
pub fn position(&self) -> u64 { self.pos } pub const fn position(&self) -> u64 { self.pos }
/// Sets the internal position. /// Sets the internal position.
/// ///
@ -226,7 +226,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
/// ///
/// This is the whole wrapped buffer, including the bytes already read. /// This is the whole wrapped buffer, including the bytes already read.
#[inline] #[inline]
pub fn get_ref(&self) -> &T { &self.inner } pub const fn get_ref(&self) -> &T { &self.inner }
/// Returns a mutable reference to the inner buffer. /// Returns a mutable reference to the inner buffer.
/// ///