-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
165e8a7
commit f15eec9
Showing
3 changed files
with
22 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// Polyfill for `Option::unwrap()` as a const fn; feature `const_option`. | ||
/// https://github.com/rust-lang/rust/issues/67441. | ||
/// TODO(MSRV): Replace this with `x.unwrap()`. | ||
/// | ||
/// `T: Copy` avoids "constant functions cannot evaluate destructors." | ||
pub const fn unwrap_const<T>(x: Option<T>) -> T | ||
where | ||
T: Copy, | ||
{ | ||
if let Some(x) = x { | ||
x | ||
} else { | ||
panic!("unwrap_const on `None`"); | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters