// Copyright 2016 Amanieu d'Antras // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. // Option::unchecked_unwrap pub trait UncheckedOptionExt { unsafe fn unchecked_unwrap(self) -> T; } impl UncheckedOptionExt for Option { #[inline] unsafe fn unchecked_unwrap(self) -> T { match self { Some(x) => x, None => unreachable(), } } } // hint::unreachable_unchecked() in release mode #[inline] unsafe fn unreachable() -> ! { if cfg!(debug_assertions) { unreachable!(); } else { core::hint::unreachable_unchecked() } }