From 3542803c4eafa23adfaa6b3327e753c1297d1b2c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 16 Jan 2025 13:35:25 +1100 Subject: [PATCH] Make Cursor methods const Mirror the `std::io::Cursor` type by making the same methods `const`. --- io/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/src/lib.rs b/io/src/lib.rs index 08a6c089d..c0bda4c97 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -201,11 +201,11 @@ pub struct Cursor { impl> Cursor { /// 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. /// @@ -226,7 +226,7 @@ impl> Cursor { /// /// 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. ///