Make Option::unwrap
unstably const
`Result::unwrap` is not eligible becuase it formats the contents of the `Err` variant. `unwrap_or`, `unwrap_or_else` and friends are not eligible because they drop things or invoke closures.
This commit is contained in:
parent
6b09c37ddc
commit
fc2c1f8ddc
2 changed files with 3 additions and 1 deletions
|
@ -380,7 +380,8 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn unwrap(self) -> T {
|
||||
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
|
||||
pub const fn unwrap(self) -> T {
|
||||
match self {
|
||||
Some(val) => val,
|
||||
None => panic!("called `Option::unwrap()` on a `None` value"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue