Make Cursor methods const
Mirror the `std::io::Cursor` type by making the same methods `const`.
This commit is contained in:
parent
1af293efe3
commit
3542803c4e
|
@ -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.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue