Struct protobuf::SingularPtrField
source · [−]pub struct SingularPtrField<T> { /* private fields */ }
Expand description
Like Option<Box<T>>
, but keeps the actual element on clear
.
Implementations
sourceimpl<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) -> T where
F: FnOnce() -> T,
pub fn unwrap_or_else<F>(self, f: F) -> T where
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.
sourceimpl<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
sourceimpl<T: Clone> Clone for SingularPtrField<T>
impl<T: Clone> Clone for SingularPtrField<T>
sourcefn clone(&self) -> SingularPtrField<T>
fn clone(&self) -> SingularPtrField<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 SingularPtrField<T>
impl<T: Debug> Debug for SingularPtrField<T>
sourceimpl<T> Default for SingularPtrField<T>
impl<T> Default for SingularPtrField<T>
sourcefn default() -> SingularPtrField<T>
fn default() -> SingularPtrField<T>
Returns the “default value” for a type. Read more
sourceimpl<T> From<Option<T>> for SingularPtrField<T>
impl<T> From<Option<T>> for SingularPtrField<T>
sourceimpl<T: Hash> Hash for SingularPtrField<T>
impl<T: Hash> Hash for SingularPtrField<T>
sourceimpl<'a, T> IntoIterator for &'a SingularPtrField<T>
impl<'a, T> IntoIterator for &'a SingularPtrField<T>
sourceimpl<T: PartialEq> PartialEq<SingularPtrField<T>> for SingularPtrField<T>
impl<T: PartialEq> PartialEq<SingularPtrField<T>> for SingularPtrField<T>
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
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