mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
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.
This commit is contained in:
commit
71d3c7790f
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user