]>
git.proxmox.com Git - rustc.git/blob - vendor/parking_lot_core-0.7.2/src/util.rs
1 // Copyright 2016 Amanieu d'Antras
3 // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4 // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5 // http://opensource.org/licenses/MIT>, at your option. This file may not be
6 // copied, modified, or distributed except according to those terms.
8 // Option::unchecked_unwrap
9 pub trait UncheckedOptionExt
<T
> {
10 unsafe fn unchecked_unwrap(self) -> T
;
13 impl<T
> UncheckedOptionExt
<T
> for Option
<T
> {
15 unsafe fn unchecked_unwrap(self) -> T
{
18 None
=> unreachable(),
23 // hint::unreachable_unchecked() in release mode
25 unsafe fn unreachable() -> ! {
26 if cfg
!(debug_assertions
) {
29 core
::hint
::unreachable_unchecked()