[−]Struct gpapi::SingularPtrField
Like Option<Box<T>>
, but keeps the actual element on clear
.
Methods
impl<T> SingularPtrField<T>
pub fn some(value: T) -> SingularPtrField<T>
Construct SingularPtrField
from given object.
pub fn none() -> SingularPtrField<T>
Construct an empty SingularPtrField
.
pub fn from_option(option: Option<T>) -> SingularPtrField<T>
Construct SingularPtrField
from optional.
pub fn is_some(&self) -> bool
True iff this object contains data.
pub fn is_none(&self) -> bool
True iff this object contains no data.
pub fn into_option(self) -> Option<T>
Convert into Option<T>
.
pub fn as_ref(&'a self) -> Option<&'a T>
View data as reference option.
pub fn as_mut(&'a mut self) -> Option<&'a mut T>
View data as mutable reference option.
pub fn get_ref(&'a self) -> &'a T
Get data as reference. Panics if empty.
pub fn get_mut_ref(&'a mut self) -> &'a mut T
Get data as mutable reference. Panics if empty.
pub fn unwrap(self) -> T
Take the data. Panics if empty
pub fn unwrap_or(self, def: T) -> T
Take the data or return supplied default element if empty.
pub fn unwrap_or_else<F>(self, f: F) -> T where
F: FnOnce() -> T,
F: FnOnce() -> T,
Take the data or return supplied default element if empty.
pub fn map<U, F>(self, f: F) -> SingularPtrField<U> where
F: FnOnce(T) -> U,
F: FnOnce(T) -> U,
Apply given function to contained data to construct another SingularPtrField
.
Returns empty SingularPtrField
if this object is empty.
pub fn iter(&'a self) -> IntoIter<&'a T>
View data as iterator.
pub fn mut_iter(&'a mut self) -> IntoIter<&'a mut T>
View data as mutable iterator.
pub fn take(&mut self) -> Option<T>
Take data as option, leaving this object empty.
pub fn clear(&mut self)
Clear this object, but do not call destructor of underlying data.
impl<T> SingularPtrField<T> where
T: Clear + Default,
T: Clear + Default,
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 mut self) -> &'a mut T
Trait Implementations
impl<T> Hash for SingularPtrField<T> where
T: Hash,
T: Hash,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Default for SingularPtrField<T>
fn default() -> SingularPtrField<T>
impl<T> From<Option<T>> for SingularPtrField<T>
fn from(o: Option<T>) -> SingularPtrField<T>
impl<M> MessageField<M> for SingularPtrField<M> where
M: Message + Default,
M: Message + Default,
fn get_message(&self) -> &M
fn mut_message(&mut self) -> &mut M
fn set_message(&mut self, message: M)
fn set_default(&mut self) -> &mut M
impl<'a, T> IntoIterator for &'a SingularPtrField<T>
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?
fn into_iter(self) -> IntoIter<&'a T>
impl<T> Eq for SingularPtrField<T> where
T: Eq,
T: Eq,
impl<T> Serialize for SingularPtrField<T> where
T: Serialize,
T: Serialize,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl<T> PartialEq<SingularPtrField<T>> for SingularPtrField<T> where
T: PartialEq<T>,
T: PartialEq<T>,
fn eq(&self, other: &SingularPtrField<T>) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'de, T> Deserialize<'de> for SingularPtrField<T> where
T: Deserialize<'de>,
T: Deserialize<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<SingularPtrField<T>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
deserializer: D
) -> Result<SingularPtrField<T>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl<T> Clone for SingularPtrField<T> where
T: Clone,
T: Clone,
fn clone(&self) -> SingularPtrField<T>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Debug for SingularPtrField<T> where
T: Debug,
T: Debug,
Auto Trait Implementations
impl<T> Send for SingularPtrField<T> where
T: Send,
T: Send,
impl<T> Sync for SingularPtrField<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,