Struct protobuf::SingularPtrField
source · 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<SingularPtrField<T>> for SingularPtrField<T>
impl<T: PartialEq> PartialEq<SingularPtrField<T>> for SingularPtrField<T>
source§fn eq(&self, other: &SingularPtrField<T>) -> bool
fn eq(&self, other: &SingularPtrField<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: Eq> Eq for SingularPtrField<T>
Auto Trait Implementations§
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