We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7fbd4ce commit 00dba3aCopy full SHA for 00dba3a
library/core/src/option.rs
@@ -646,7 +646,8 @@ impl<T> Option<T> {
646
/// ```
647
#[inline]
648
#[stable(feature = "rust1", since = "1.0.0")]
649
- pub fn as_mut(&mut self) -> Option<&mut T> {
+ #[rustc_const_unstable(feature = "const_option", issue = "67441")]
650
+ pub const fn as_mut(&mut self) -> Option<&mut T> {
651
match *self {
652
Some(ref mut x) => Some(x),
653
None => None,
library/core/tests/option.rs
@@ -380,6 +380,14 @@ const fn option_const_mut() {
380
381
let _take = option.take();
382
let _replace = option.replace(42);
383
+
384
+ {
385
+ let as_mut = option.as_mut();
386
+ match as_mut {
387
+ Some(v) => *v = 32,
388
+ None => unreachable!(),
389
+ }
390
391
}
392
393
#[test]
0 commit comments