Struct emf_core_base_rs_ffi::collections::Optional[][src]

#[repr(C)]
pub struct Optional<T> where
    T: Copy + Sized
{ /* fields omitted */ }

A type containing an optional value.

Implementations

impl<T> Optional<T> where
    T: Copy + Sized
[src]

pub fn some(val: T) -> Self[src]

Creates a new Optional<T> containing the value.

pub fn none() -> Self[src]

Creates an empty Optional<T>.

pub fn is_some(&self) -> bool[src]

Returns true if the optional contains a value.

pub fn is_none(&self) -> bool[src]

Returns true if the optional is empty.

pub fn as_ref(&self) -> Optional<&T>[src]

Maps the Optional<T> to Optional<&T>.

pub fn to_option(self) -> Option<T>[src]

Maps the Optional<T> to Option<T>.

pub fn expect(self, msg: &str) -> T[src]

Returns the contained value.

Panics

Panics if no value is contained with a custom panic message provided by msg.

pub fn unwrap(self) -> T[src]

Returns the contained value.

Panics

Panics if no value is contained.

pub fn unwrap_or(self, default: T) -> T[src]

Returns the contained value or a default.

pub fn unwrap_or_else<F>(self, f: F) -> T where
    F: FnOnce() -> T, 
[src]

Returns the contained value or computes it from a closure.

pub fn map<U, F>(self, f: F) -> Optional<U> where
    U: Copy + Sized,
    F: FnOnce(T) -> U, 
[src]

Maps an Optional<T> to Optional<U> by applying a function to the contained value.

pub fn map_or<U, F>(self, default: U, f: F) -> U where
    F: FnOnce(T) -> U, 
[src]

Returns the application of the closure to the contained value or a default value.

pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U where
    D: FnOnce() -> U,
    F: FnOnce(T) -> U, 
[src]

Applies a function to the contained value (if any), or computes a default (if not).

pub fn ok_or<E>(self, err: E) -> Result<T, E> where
    E: Copy + Sized
[src]

Transforms the Optional<T> into a Result<T, E>.

pub fn ok_or_else<E, F>(self, f: F) -> Result<T, E> where
    E: Copy + Sized,
    F: FnOnce() -> E, 
[src]

Transforms the Optional<T> into a Result<T, E> by mapping the contained value or computing an error value from a closure.

Trait Implementations

impl<T: Clone> Clone for Optional<T> where
    T: Copy + Sized
[src]

impl<T: Copy> Copy for Optional<T> where
    T: Copy + Sized
[src]

impl<T> Debug for Optional<T> where
    T: Copy + Sized + Debug
[src]

impl<T> Default for Optional<T> where
    T: Copy + Sized
[src]

impl<T> Eq for Optional<T> where
    T: Copy + Sized + PartialEq + Eq
[src]

impl<T> From<Option<T>> for Optional<T> where
    T: Copy + Sized
[src]

impl<T> PartialEq<Optional<T>> for Optional<T> where
    T: Copy + Sized + PartialEq
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Optional<T> where
    T: RefUnwindSafe

impl<T> Send for Optional<T> where
    T: Send

impl<T> Sync for Optional<T> where
    T: Sync

impl<T> Unpin for Optional<T> where
    T: Unpin

impl<T> UnwindSafe for Optional<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.