Skip to content

Commit

Permalink
Rollup merge of rust-lang#76543 - ssomers:btree_cleanup_4, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

Document btree's unwrap_unchecked

rust-lang#74693's second wind
  • Loading branch information
tmandry committed Sep 10, 2020
2 parents ba6e2b3 + f42dac0 commit 8bf03c3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/alloc/src/collections/btree/mod.rs
Expand Up @@ -13,6 +13,9 @@ trait Recover<Q: ?Sized> {
fn replace(&mut self, key: Self::Key) -> Option<Self::Key>;
}

/// Same purpose as `Option::unwrap` but doesn't always guarantee a panic
/// if the option contains no value.
/// SAFETY: the caller must ensure that the option contains a value.
#[inline(always)]
pub unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
val.unwrap_or_else(|| {
Expand Down

0 comments on commit 8bf03c3

Please sign in to comment.