pub struct SingularPtrField<T> { /* private fields */ }
Expand description
Like Option<Box<T>>
, but keeps the actual element on clear
.
Implementations§
Source§impl<T> SingularPtrField<T>
impl<T> SingularPtrField<T>
Sourcepub fn some(value: T) -> SingularPtrField<T>
pub fn some(value: T) -> SingularPtrField<T>
Construct SingularPtrField
from given object.
Sourcepub fn none() -> SingularPtrField<T>
pub fn none() -> SingularPtrField<T>
Construct an empty SingularPtrField
.
Sourcepub fn from_option(option: Option<T>) -> SingularPtrField<T>
pub fn from_option(option: Option<T>) -> SingularPtrField<T>
Construct SingularPtrField
from optional.
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Convert into Option<T>
.
Sourcepub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T
pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T
Get data as mutable reference. Panics if empty.
Sourcepub fn unwrap_or_else<F>(self, f: F) -> Twhere
F: FnOnce() -> T,
pub fn unwrap_or_else<F>(self, f: F) -> Twhere
F: FnOnce() -> T,
Take the data or return supplied default element if empty.
Sourcepub fn map<U, F>(self, f: F) -> SingularPtrField<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> SingularPtrField<U>where
F: FnOnce(T) -> U,
Apply given function to contained data to construct another SingularPtrField
.
Returns empty SingularPtrField
if this object is empty.
Source§impl<T: Default + Clear> SingularPtrField<T>
impl<T: Default + Clear> SingularPtrField<T>
Sourcepub fn unwrap_or_default(self) -> T
pub fn unwrap_or_default(self) -> T
Get contained data, consume self. Return default value for type if this is empty.
Sourcepub fn set_default<'a>(&'a mut self) -> &'a mut T
pub fn set_default<'a>(&'a mut self) -> &'a mut T
Initialize this object with default value. This operation can be more efficient then construction of clear element, because it may reuse previously contained object.
Trait Implementations§
Source§impl<T: Clone> Clone for SingularPtrField<T>
impl<T: Clone> Clone for SingularPtrField<T>
Source§fn clone(&self) -> SingularPtrField<T>
fn clone(&self) -> SingularPtrField<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for SingularPtrField<T>
impl<T: Debug> Debug for SingularPtrField<T>
Source§impl<T> Default for SingularPtrField<T>
impl<T> Default for SingularPtrField<T>
Source§fn default() -> SingularPtrField<T>
fn default() -> SingularPtrField<T>
Returns the “default value” for a type. Read more
Source§impl<T> From<Option<T>> for SingularPtrField<T>
impl<T> From<Option<T>> for SingularPtrField<T>
Source§impl<T: Hash> Hash for SingularPtrField<T>
impl<T: Hash> Hash for SingularPtrField<T>
Source§impl<'a, T> IntoIterator for &'a SingularPtrField<T>
impl<'a, T> IntoIterator for &'a SingularPtrField<T>
Source§impl<T: PartialEq> PartialEq for SingularPtrField<T>
impl<T: PartialEq> PartialEq for SingularPtrField<T>
impl<T: Eq> Eq for SingularPtrField<T>
Auto Trait Implementations§
impl<T> Freeze for SingularPtrField<T>
impl<T> RefUnwindSafe for SingularPtrField<T>where
T: RefUnwindSafe,
impl<T> Send for SingularPtrField<T>where
T: Send,
impl<T> Sync for SingularPtrField<T>where
T: Sync,
impl<T> Unpin for SingularPtrField<T>
impl<T> UnwindSafe for SingularPtrField<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