Skip to content

Commit

Permalink
Merge rust-bitcoin#3911: Make Cursor methods const
Browse files Browse the repository at this point in the history
9ef8e29 api: Run just check-api (Tobin C. Harding)
3542803 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 9ef8e29
  apoelstra:
    ACK 9ef8e29; successfully ran local tests

Tree-SHA512: 60ad8169c9bcc90360fcd3c3439256d86af4a77733a00a66e9b155bdb89580d4971efd55a93f1873363ed9d24f0b2b8f5a0da1857bb5aa8a112b13e27239a984
  • Loading branch information
apoelstra committed Jan 16, 2025
2 parents 70fc399 + 9ef8e29 commit dc76043
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api/io/all-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock
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::ToStd<T>::new(inner: T) -> Self
pub const fn bitcoin_io::from_std<T>(std_io: T) -> bitcoin_io::FromStd<T>
Expand Down Expand Up @@ -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>::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_ref(&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>::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>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::cause(&self) -> core::option::Option<&dyn core::error::Error>
Expand Down
6 changes: 3 additions & 3 deletions api/io/alloc-only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock
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 fn &[u8]::consume(&mut self, amount: usize)
pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
Expand All @@ -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>::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_ref(&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>::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>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
Expand Down
6 changes: 3 additions & 3 deletions api/io/no-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ pub bitcoin_io::ErrorKind::TimedOut
pub bitcoin_io::ErrorKind::UnexpectedEof
pub bitcoin_io::ErrorKind::WouldBlock
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 fn &[u8]::consume(&mut self, amount: usize)
pub fn &[u8]::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
Expand All @@ -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>::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_ref(&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>::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>::set_position(&mut self, position: u64)
pub fn bitcoin_io::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
Expand Down
6 changes: 3 additions & 3 deletions io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ pub struct Cursor<T> {
impl<T: AsRef<[u8]>> Cursor<T> {
/// Constructs a new `Cursor` by wrapping `inner`.
#[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.
#[inline]
pub fn position(&self) -> u64 { self.pos }
pub const fn position(&self) -> u64 { self.pos }

/// Sets the internal position.
///
Expand All @@ -226,7 +226,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
///
/// This is the whole wrapped buffer, including the bytes already read.
#[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.
///
Expand Down

0 comments on commit dc76043

Please sign in to comment.