Struct protobuf::SingularField
source · pub struct SingularField<T> { /* private fields */ }
Expand description
Like Option<T>
, but keeps the actual element on clear
.
Implementations§
source§impl<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) -> Twhere
F: FnOnce() -> T,
pub fn unwrap_or_else<F>(self, f: F) -> Twhere 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
.
source§impl<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
.
source§impl<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§
source§impl<T: Clone + Default> Clone for SingularField<T>
impl<T: Clone + Default> Clone for SingularField<T>
source§fn clone(&self) -> SingularField<T>
fn clone(&self) -> SingularField<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 SingularField<T>
impl<T: Debug> Debug for SingularField<T>
source§impl<T: Default> Default for SingularField<T>
impl<T: Default> Default for SingularField<T>
source§fn default() -> SingularField<T>
fn default() -> SingularField<T>
Returns the “default value” for a type. Read more
source§impl<T: Hash> Hash for SingularField<T>
impl<T: Hash> Hash for SingularField<T>
source§impl<'a, T> IntoIterator for &'a SingularField<T>
impl<'a, T> IntoIterator for &'a SingularField<T>
source§impl<T: PartialEq> PartialEq<SingularField<T>> for SingularField<T>
impl<T: PartialEq> PartialEq<SingularField<T>> for SingularField<T>
source§fn eq(&self, other: &SingularField<T>) -> bool
fn eq(&self, other: &SingularField<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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§
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