Struct protobuf::SingularField [−][src]
pub struct SingularField<T> { /* fields omitted */ }
Like Option<T>
, but keeps the actual element on clear
.
Methods
impl<T> SingularField<T>
[src]
impl<T> SingularField<T>
pub fn some(value: T) -> SingularField<T>
[src]
pub fn some(value: T) -> SingularField<T>
Construct this object from given value.
pub fn is_some(&self) -> bool
[src]
pub fn is_some(&self) -> bool
True iff this object contains data.
pub fn is_none(&self) -> bool
[src]
pub fn is_none(&self) -> bool
True iff this object contains no data.
pub fn into_option(self) -> Option<T>
[src]
pub fn into_option(self) -> Option<T>
Convert this object into Option
.
pub fn as_ref<'a>(&'a self) -> Option<&'a T>
[src]
pub fn as_ref<'a>(&'a self) -> Option<&'a T>
View data as Option
.
pub fn as_mut<'a>(&'a mut self) -> Option<&'a mut T>
[src]
pub fn as_mut<'a>(&'a mut self) -> Option<&'a mut T>
View data as mutable Option
.
pub fn unwrap_ref<'a>(&'a self) -> &'a T
[src]
pub fn unwrap_ref<'a>(&'a self) -> &'a T
Unwrap data as reference.
pub fn unwrap_mut_ref<'a>(&'a mut self) -> &'a mut T
[src]
pub fn unwrap_mut_ref<'a>(&'a mut self) -> &'a mut T
Unwrap data as mutable reference.
pub fn unwrap(self) -> T
[src]
pub fn unwrap(self) -> T
Unwrap data, panic if not set.
pub fn unwrap_or(self, def: T) -> T
[src]
pub fn unwrap_or(self, def: T) -> T
Unwrap data or return given default value.
pub fn unwrap_or_else<F>(self, f: F) -> T where
F: FnOnce() -> T,
[src]
pub fn unwrap_or_else<F>(self, f: F) -> T where
F: FnOnce() -> T,
Unwrap data or return given default value.
pub fn map<U, F>(self, f: F) -> SingularPtrField<U> where
F: FnOnce(T) -> U,
[src]
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
.
pub fn iter<'a>(&'a self) -> IntoIter<&'a T>
[src]
pub fn iter<'a>(&'a self) -> IntoIter<&'a T>
View as iterator over references.
pub fn mut_iter<'a>(&'a mut self) -> IntoIter<&'a mut T>
[src]
pub fn mut_iter<'a>(&'a mut self) -> IntoIter<&'a mut T>
View as iterator over mutable references.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clear this object. Note, contained object destructor is not called, so allocated memory could be reused.
impl<T: Default> SingularField<T>
[src]
impl<T: Default> SingularField<T>
pub fn none() -> SingularField<T>
[src]
pub fn none() -> SingularField<T>
Construct a SingularField
with no data.
pub fn from_option(option: Option<T>) -> SingularField<T>
[src]
pub fn from_option(option: Option<T>) -> SingularField<T>
Construct SingularField
from Option
.
pub fn take(&mut self) -> Option<T>
[src]
pub fn take(&mut self) -> Option<T>
Return data as option, clear this object.
impl<T: Default + Clear> SingularField<T>
[src]
impl<T: Default + Clear> SingularField<T>
pub fn unwrap_or_default(self) -> T
[src]
pub fn unwrap_or_default(self) -> T
Get contained data, consume self. Return default value for type if this is empty.
pub fn set_default<'a>(&'a mut self) -> &'a mut T
[src]
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
impl<T: Default> Default for SingularField<T>
[src]
impl<T: Default> Default for SingularField<T>
fn default() -> SingularField<T>
[src]
fn default() -> SingularField<T>
Returns the "default value" for a type. Read more
impl<T: Clone + Default> Clone for SingularField<T>
[src]
impl<T: Clone + Default> Clone for SingularField<T>
fn clone(&self) -> SingularField<T>
[src]
fn clone(&self) -> SingularField<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for SingularField<T>
[src]
impl<T: Debug> Debug for SingularField<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: PartialEq> PartialEq for SingularField<T>
[src]
impl<T: PartialEq> PartialEq for SingularField<T>
fn eq(&self, other: &SingularField<T>) -> bool
[src]
fn eq(&self, other: &SingularField<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: Eq> Eq for SingularField<T>
[src]
impl<T: Eq> Eq for SingularField<T>
impl<T: Hash> Hash for SingularField<T>
[src]
impl<T: Hash> Hash for SingularField<T>
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, T> IntoIterator for &'a SingularField<T>
[src]
impl<'a, T> IntoIterator for &'a SingularField<T>
Auto Trait Implementations
impl<T> Send for SingularField<T> where
T: Send,
impl<T> Send for SingularField<T> where
T: Send,
impl<T> Sync for SingularField<T> where
T: Sync,
impl<T> Sync for SingularField<T> where
T: Sync,