summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-20 20:10:12 +0100
committerGitHub <noreply@github.com>2024-11-20 20:10:12 +0100
commit71d3c7790f7bcbfc254270ef76c3d772104321e1 (patch)
tree736624d672ed3d319f445372f719172d4121d34e
parent0576cc987b2e77de260bfb8094b2d1cda072a2de (diff)
parent26c4893ae6a6bd5d611fd6c7b3c803a720138d40 (diff)
downloadrust-71d3c7790f7bcbfc254270ef76c3d772104321e1.tar.gz
rust-71d3c7790f7bcbfc254270ef76c3d772104321e1.zip
Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplett
Mark `get_mut` and `set_position` in `std::io::Cursor` as const.

Relevant tracking issue: #130801

The methods `get_mut` and `set_position` can trivially be marked as const due to #57349 being stabilised.
-rw-r--r--library/std/src/io/cursor.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/std/src/io/cursor.rs b/library/std/src/io/cursor.rs
index 9f913eae095..fbfdb4fa023 100644
--- a/library/std/src/io/cursor.rs
+++ b/library/std/src/io/cursor.rs
@@ -153,7 +153,8 @@ impl<T> Cursor<T> {
     /// let reference = buff.get_mut();
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn get_mut(&mut self) -> &mut T {
+    #[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")]
+    pub const fn get_mut(&mut self) -> &mut T {
         &mut self.inner
     }
 
@@ -200,7 +201,8 @@ impl<T> Cursor<T> {
     /// assert_eq!(buff.position(), 4);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn set_position(&mut self, pos: u64) {
+    #[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")]
+    pub const fn set_position(&mut self, pos: u64) {
         self.pos = pos;
     }
 }