[][src]Trait alloc_wg::UncheckedOptionExt

pub trait UncheckedOptionExt<T> {
    unsafe fn unwrap_unchecked(self) -> T;
unsafe fn unwrap_none_unchecked(self); }

An extension trait for Option<T> providing unchecked unwrapping.

Required methods

unsafe fn unwrap_unchecked(self) -> T

Unwraps an Option, yielding the content of a Some.

Safety

The Option has to be Some

Example

use alloc_wg::UncheckedOptionExt;

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

unsafe fn unwrap_none_unchecked(self)

Unwraps an Option, expecting None and returning nothing.

Safety

The Option has to be None.

Example

use alloc_wg::UncheckedOptionExt;
use std::collections::HashMap;

let mut squares = HashMap::new();
for i in -10..=10 {
    unsafe {
        squares.insert(i, i * i).unwrap_none_unchecked();
    }
}
Loading content...

Implementations on Foreign Types

impl<T> UncheckedOptionExt<T> for Option<T>[src]

Loading content...

Implementors

Loading content...