Struct protobuf::SingularField[][src]

pub struct SingularField<T> { /* fields omitted */ }

Like Option<T>, but keeps the actual element on clear.

Implementations

impl<T> SingularField<T>[src]

pub fn some(value: T) -> SingularField<T>[src]

Construct this object from given value.

pub fn is_some(&self) -> bool[src]

True iff this object contains data.

pub fn is_none(&self) -> bool[src]

True iff this object contains no data.

pub fn into_option(self) -> Option<T>[src]

Convert this object into Option.

pub fn as_ref<'a>(&'a self) -> Option<&'a T>[src]

View data as Option.

pub fn as_mut<'a>(&'a mut self) -> Option<&'a mut T>[src]

View data as mutable Option.

pub fn unwrap_ref<'a>(&'a self) -> &'a T[src]

Unwrap data as reference.

pub fn unwrap_mut_ref<'a>(&'a mut self) -> &'a mut T[src]

Unwrap data as mutable reference.

pub fn unwrap(self) -> T[src]

Unwrap data, panic if not set.

pub fn unwrap_or(self, def: T) -> T[src]

Unwrap data or return given default value.

pub fn unwrap_or_else<F>(self, f: F) -> T where
    F: FnOnce() -> T, 
[src]

Unwrap data or return given default value.

pub fn map<U, F>(self, f: F) -> SingularPtrField<U> where
    F: FnOnce(T) -> U, 
[src]

Apply a function to contained element and store result in new SingularPtrField.

pub fn iter<'a>(&'a self) -> IntoIter<&'a T>[src]

View as iterator over references.

pub fn mut_iter<'a>(&'a mut self) -> IntoIter<&'a mut T>[src]

View as iterator over mutable references.

pub fn clear(&mut self)[src]

Clear this object. Note, contained object destructor is not called, so allocated memory could be reused.

impl<T: Default> SingularField<T>[src]

pub fn none() -> SingularField<T>[src]

Construct a SingularField with no data.

pub fn from_option(option: Option<T>) -> SingularField<T>[src]

Construct SingularField from Option.

pub fn take(&mut self) -> Option<T>[src]

Return data as option, clear this object.

impl<T: Default + Clear> SingularField<T>[src]

pub fn unwrap_or_default(self) -> T[src]

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]

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: Clone + Default> Clone for SingularField<T>[src]

impl<T: Debug> Debug for SingularField<T>[src]

impl<T: Default> Default for SingularField<T>[src]

impl<T: Eq> Eq for SingularField<T>[src]

impl<T: Default> From<Option<T>> for SingularField<T>[src]

impl<T: Hash> Hash for SingularField<T>[src]

impl<'a, T> IntoIterator for &'a SingularField<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = IntoIter<&'a T>

Which kind of iterator are we turning this into?

impl<T: PartialEq> PartialEq<SingularField<T>> for SingularField<T>[src]

impl<T: PbPrint> PbPrint for SingularField<T>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.