Rollup merge of #76543 - ssomers:btree_cleanup_4, r=Mark-Simulacrum

Document btree's unwrap_unchecked

#74693's second wind
This commit is contained in:
Tyler Mandry 2020-09-09 21:02:36 -07:00 committed by GitHub
commit 8bf03c3f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(|| {