pub struct Opt<T> { /* private fields */ }Implementations§
Source§impl<T> Opt<T>
impl<T> Opt<T>
pub fn is_none(&self) -> bool
pub fn is_some(&self) -> bool
pub fn set_none(&mut self)
pub fn set_some(&mut self)
pub fn set_some_value(&mut self, value: T)
pub fn expect(self, msg: &str) -> T
pub fn unwrap(self) -> T
pub fn unwrap_or(self, default: T) -> T
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Opt<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Opt<U>
Applies the function f to the value; regardless if Opt<T> is empty or not. Does not
modify the ‘emptiness’ of the option. (Note: This behavior, though consistent, may seem
strange at first.)
pub fn map_in_place<F: FnOnce(&mut T)>(&mut self, f: F)
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>( self, default: D, f: F, ) -> U
pub fn ok_or<E>(self, err: E) -> Result<T, E>
pub fn ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E>
Trait Implementations§
Source§impl<T: Ord> Ord for Opt<T>
impl<T: Ord> Ord for Opt<T>
Source§impl<T: PartialOrd> PartialOrd for Opt<T>
impl<T: PartialOrd> PartialOrd for Opt<T>
impl<T: Copy> Copy for Opt<T>
impl<T: Eq> Eq for Opt<T>
Auto Trait Implementations§
impl<T> Freeze for Opt<T>where
T: Freeze,
impl<T> RefUnwindSafe for Opt<T>where
T: RefUnwindSafe,
impl<T> Send for Opt<T>where
T: Send,
impl<T> Sync for Opt<T>where
T: Sync,
impl<T> Unpin for Opt<T>where
T: Unpin,
impl<T> UnwindSafe for Opt<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more