[][src]Trait mod_utilities::Unref

pub trait Unref {
    type Target;
    fn unref(self) -> Self::Target;
}

Convenience trait to extract a copy of a value referenced in an Option or Result

Examples

The type of the unref of Option<&T> is Option

use mod_engine::util::Unref;
let y = 32;
let x = Some(&y);
assert_eq!(x.unref(), Some(y));

Using unref on a None yields a None

use mod_engine::util::Unref;
let z: Option<&i32> = None;
assert_eq!(z.unref(), None);

Associated Types

type Target

The inner value type of the container yielded by unref

Loading content...

Required methods

fn unref(self) -> Self::Target

Extract a copy of a value referenced in an Option or Result

Loading content...

Implementations on Foreign Types

impl<'_, T> Unref for Option<&'_ T> where
    T: Copy
[src]

type Target = Option<T>

impl<'_, T> Unref for Option<&'_ mut T> where
    T: Copy
[src]

type Target = Option<T>

impl<'_, R, E> Unref for Result<&'_ R, E> where
    R: Copy
[src]

type Target = Result<R, E>

impl<'_, R, E> Unref for Result<&'_ mut R, E> where
    R: Copy
[src]

type Target = Result<R, E>

Loading content...

Implementors

Loading content...