Make Cursor methods const

Mirror the `std::io::Cursor` type by making the same methods `const`.
This commit is contained in:
Tobin C. Harding 2025-01-16 13:35:25 +11:00
parent 1af293efe3
commit 3542803c4e
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 3 additions and 3 deletions

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.
/// ///