Skip to content

Commit 3f03a0f

Browse files
authored
Rollup merge of rust-lang#130800 - bjoernager:const-mut-cursor, r=joshtriplett
Mark `get_mut` and `set_position` in `std::io::Cursor` as const. Relevant tracking issue: rust-lang#130801 The methods `get_mut` and `set_position` can trivially be marked as const due to rust-lang#57349 being stabilised.
2 parents eea7e23 + aa74e93 commit 3f03a0f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

std/src/io/cursor.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ impl<T> Cursor<T> {
153153
/// let reference = buff.get_mut();
154154
/// ```
155155
#[stable(feature = "rust1", since = "1.0.0")]
156-
pub fn get_mut(&mut self) -> &mut T {
156+
#[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")]
157+
pub const fn get_mut(&mut self) -> &mut T {
157158
&mut self.inner
158159
}
159160

@@ -200,7 +201,8 @@ impl<T> Cursor<T> {
200201
/// assert_eq!(buff.position(), 4);
201202
/// ```
202203
#[stable(feature = "rust1", since = "1.0.0")]
203-
pub fn set_position(&mut self, pos: u64) {
204+
#[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")]
205+
pub const fn set_position(&mut self, pos: u64) {
204206
self.pos = pos;
205207
}
206208
}

0 commit comments

Comments
 (0)