[][src]Trait alloc_wg::UncheckedResultExt

pub trait UncheckedResultExt<T, E> {
    unsafe fn unwrap_unchecked(self) -> T;
unsafe fn unwrap_err_unchecked(self) -> E; }

An extension trait for Result<T, E> providing unchecked unwrapping.

Required methods

unsafe fn unwrap_unchecked(self) -> T

Unwraps a Result, yielding the content of an Ok.

Safety

The Result has to be Ok

Example

use alloc_wg::UncheckedResultExt;

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

unsafe fn unwrap_err_unchecked(self) -> E

Unwraps a Result, yielding the content of an Err.

Safety

The Result has to be Err.

Example

use alloc_wg::UncheckedResultExt;

let x: Result<u32, &str> = Err("emergency failure");
unsafe {
    assert_eq!(x.unwrap_err_unchecked(), "emergency failure");
}
Loading content...

Implementations on Foreign Types

impl<T, E> UncheckedResultExt<T, E> for Result<T, E>[src]

Loading content...

Implementors

Loading content...