Skip to content

Commit ea48cf3

Browse files
authored
Rollup merge of rust-lang#131120 - tgross35:stabilize-const_option, r=RalfJung
Stabilize `const_option` This makes the following API stable in const contexts: ```rust impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } ``` The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <rust-lang#67441>
2 parents b1c4684 + 3c43a60 commit ea48cf3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tests/ui/doc/doc-fixable.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![allow(dead_code, incomplete_features)]
55
#![warn(clippy::doc_markdown)]
6-
#![feature(custom_inner_attributes, generic_const_exprs, const_option)]
6+
#![feature(custom_inner_attributes, generic_const_exprs)]
77
#![rustfmt::skip]
88

99
/// The `foo_bar` function does _nothing_. See also `foo::bar`. (note the dot there)

tests/ui/doc/doc-fixable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
#![allow(dead_code, incomplete_features)]
55
#![warn(clippy::doc_markdown)]
6-
#![feature(custom_inner_attributes, generic_const_exprs, const_option)]
6+
#![feature(custom_inner_attributes, generic_const_exprs)]
77
#![rustfmt::skip]
88

99
/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)

0 commit comments

Comments
 (0)