pub trait UncheckedUnwrap<T> {
    unsafe fn unchecked_unwrap(self) -> T;
}
Expand description

Trait for unchecked_unwrap.

Required Methods

Unwraps an Option or Result, yielding the content of a Some or Ok. This is the unchecked alternative to Option::unwrap and Result::unwrap.

Panics

Only panics if the crate features debug_assertions and debug_checks are on.

Panics if the value is a None or Err, if Result with a panic massage provided by the Err’s value.

Safety

Callers of this function are responsible that Option or Result carries a Some or Ok.

Failing that, the returned value may reference invalid memory or cause undefined behaviour.

Examples
use unchecked_unwrap::*;

let x = Some("air");
assert_eq!(unsafe { x.unchecked_unwrap() }, "air");

let x: Result<u32, &str> = Ok(2);
assert_eq!(unsafe { x.unchecked_unwrap() }, 2);

Implementations on Foreign Types

Unwraps a Option, yielding the content of an Some. This is the unchecked alternative to unwrap.

Unwraps a Result, yielding the content of an Ok. This is the unchecked alternative to unwrap.

Implementors