Struct protobuf::SingularField
source · [−]pub struct SingularField<T> { /* private fields */ }
Expand description
Like Option<T>
, but keeps the actual element on clear
.
Implementations
sourceimpl<T> SingularField<T>
impl<T> SingularField<T>
sourcepub fn some(value: T) -> SingularField<T>
pub fn some(value: T) -> SingularField<T>
Construct this object from given value.
sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Convert this object into Option
.
sourcepub fn unwrap_ref<'a>(&'a self) -> &'a T
pub fn unwrap_ref<'a>(&'a self) -> &'a T
Unwrap data as reference.
sourcepub fn unwrap_mut_ref<'a>(&'a mut self) -> &'a mut T
pub fn unwrap_mut_ref<'a>(&'a mut self) -> &'a mut T
Unwrap data as mutable reference.
sourcepub fn unwrap_or_else<F>(self, f: F) -> T where
F: FnOnce() -> T,
pub fn unwrap_or_else<F>(self, f: F) -> T where
F: FnOnce() -> T,
Unwrap data or return given default value.
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 a function to contained element and store result in new SingularPtrField
.
sourceimpl<T: Default> SingularField<T>
impl<T: Default> SingularField<T>
sourcepub fn none() -> SingularField<T>
pub fn none() -> SingularField<T>
Construct a SingularField
with no data.
sourcepub fn from_option(option: Option<T>) -> SingularField<T>
pub fn from_option(option: Option<T>) -> SingularField<T>
Construct SingularField
from Option
.
sourceimpl<T: Default + Clear> SingularField<T>
impl<T: Default + Clear> SingularField<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
sourceimpl<T: Clone + Default> Clone for SingularField<T>
impl<T: Clone + Default> Clone for SingularField<T>
sourcefn clone(&self) -> SingularField<T>
fn clone(&self) -> SingularField<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for SingularField<T>
impl<T: Debug> Debug for SingularField<T>
sourceimpl<T: Default> Default for SingularField<T>
impl<T: Default> Default for SingularField<T>
sourcefn default() -> SingularField<T>
fn default() -> SingularField<T>
Returns the “default value” for a type. Read more
sourceimpl<T: Default> From<Option<T>> for SingularField<T>
impl<T: Default> From<Option<T>> for SingularField<T>
sourceimpl<T: Hash> Hash for SingularField<T>
impl<T: Hash> Hash for SingularField<T>
sourceimpl<'a, T> IntoIterator for &'a SingularField<T>
impl<'a, T> IntoIterator for &'a SingularField<T>
sourceimpl<T: PartialEq> PartialEq<SingularField<T>> for SingularField<T>
impl<T: PartialEq> PartialEq<SingularField<T>> for SingularField<T>
impl<T: Eq> Eq for SingularField<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SingularField<T> where
T: RefUnwindSafe,
impl<T> Send for SingularField<T> where
T: Send,
impl<T> Sync for SingularField<T> where
T: Sync,
impl<T> Unpin for SingularField<T> where
T: Unpin,
impl<T> UnwindSafe for SingularField<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more