Struct protobuf::MessageField
source · [−]Expand description
Wrapper around Option<Box<T>>
, convenient newtype.
Examples
let mut customer = Customer::new();
// field of type `SingularPtrField` can be initialized like this
customer.address = MessageField::some(make_address());
// or using `Option` and `Into`
customer.address = Some(make_address()).into();
Tuple Fields
0: Option<Box<T>>
Implementations
sourceimpl<T> MessageField<T>
impl<T> MessageField<T>
sourcepub fn some(value: T) -> MessageField<T>
pub fn some(value: T) -> MessageField<T>
Construct SingularPtrField
from given object.
sourcepub const fn none() -> MessageField<T>
pub const fn none() -> MessageField<T>
Construct an empty SingularPtrField
.
sourcepub fn from_option(option: Option<T>) -> MessageField<T>
pub fn from_option(option: Option<T>) -> MessageField<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 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) -> MessageField<U> where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> MessageField<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> MessageField<T>
impl<T: Default> MessageField<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.
sourceimpl<M: Message> MessageField<M>
impl<M: Message> MessageField<M>
sourcepub fn get_or_default(&self) -> &M
pub fn get_or_default(&self) -> &M
Get a reference to contained value or a default instance.
sourcepub fn mut_or_insert_default(&mut self) -> &mut M
pub fn mut_or_insert_default(&mut self) -> &mut M
Get a mutable reference to contained value, initialize if not initialized yet.
Trait Implementations
sourceimpl<T: Clone> Clone for MessageField<T>
impl<T: Clone> Clone for MessageField<T>
sourcefn clone(&self) -> MessageField<T>
fn clone(&self) -> MessageField<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 MessageField<T>
impl<T: Debug> Debug for MessageField<T>
sourceimpl<T> Default for MessageField<T>
impl<T> Default for MessageField<T>
sourcefn default() -> MessageField<T>
fn default() -> MessageField<T>
Returns the “default value” for a type. Read more
sourceimpl<M: Message> Deref for MessageField<M>
impl<M: Message> Deref for MessageField<M>
Get a reference to contained value or a default instance if the field is not initialized.
sourceimpl<T> From<Option<T>> for MessageField<T>
impl<T> From<Option<T>> for MessageField<T>
We don’t have From<Option<Box<T>>> for MessageField<T>
because
it would make type inference worse.
sourceimpl<T: Hash> Hash for MessageField<T>
impl<T: Hash> Hash for MessageField<T>
sourceimpl<'a, T> IntoIterator for &'a MessageField<T>
impl<'a, T> IntoIterator for &'a MessageField<T>
sourceimpl<T: PartialEq> PartialEq<MessageField<T>> for MessageField<T>
impl<T: PartialEq> PartialEq<MessageField<T>> for MessageField<T>
sourcefn eq(&self, other: &MessageField<T>) -> bool
fn eq(&self, other: &MessageField<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MessageField<T>) -> bool
fn ne(&self, other: &MessageField<T>) -> bool
This method tests for !=
.
impl<T: Eq> Eq for MessageField<T>
impl<T> StructuralEq for MessageField<T>
impl<T> StructuralPartialEq for MessageField<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for MessageField<T> where
T: RefUnwindSafe,
impl<T> Send for MessageField<T> where
T: Send,
impl<T> Sync for MessageField<T> where
T: Sync,
impl<T> Unpin for MessageField<T>
impl<T> UnwindSafe for MessageField<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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more