Trait Gettable

Source
pub trait Gettable {
    type Res;

    // Required method
    fn get(self) -> Self::Res;
}

Required Associated Types§

Required Methods§

Source

fn get(self) -> Self::Res

Implementations on Foreign Types§

Source§

impl<T: Empty> Gettable for Option<T>

Source§

fn get(self) -> T

Moves the value v out of the Roption<T> if it is Some(v).

§Panics

Panics if the self value equals None.

§Safety note

In general, because this function may panic, its use is discouraged. Instead, prefer to use pattern matching and handle the None case explicitly.

§Examples
let x = Some("air");
assert_eq!(x.get(), "air");
let x: Roption<&str> = None;
assert_eq!(x.get(), "air"); // fails
Source§

type Res = T

Source§

impl<T: Empty, E> Gettable for Result<T, E>

Source§

fn get(self) -> T

Safely unwraps a Result, yielding the content of an Ok.

§Examples
let x: Rresult<u32, &str> = Ok(2);
assert_eq!(x.unwrap(), 2);
let x: Rresult<u32, &str> = Err("emergency failure");
x.get();
Source§

type Res = T

Implementors§