Struct emf_core_base_rs_ffi::collections::Optional [−][src]
A type containing an optional value.
Implementations
impl<T> Optional<T> where
T: Copy + Sized,
[src]
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]
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]
F: FnOnce() -> T,
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]
U: Copy + Sized,
F: FnOnce(T) -> U,
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]
F: FnOnce(T) -> U,
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]
D: FnOnce() -> U,
F: FnOnce(T) -> U,
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]
E: Copy + Sized,
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]
E: Copy + Sized,
F: FnOnce() -> E,
Transforms the Optional<T>
into a Result<T, E>
by mapping the contained value or
computing an error value from a closure.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Optional<T> where
T: RefUnwindSafe,
impl<T> RefUnwindSafe for Optional<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Optional<T> where
T: UnwindSafe,
impl<T> UnwindSafe for Optional<T> where
T: UnwindSafe,