#[repr(C)]pub struct TypedValue<T>(/* private fields */);Expand description
A statically typed Value.
It dereferences to Value and can be used everywhere Value references are
accepted.
See the module documentation for more details.
Implementations§
Source§impl<'a, T: FromValueOptional<'a> + SetValue> TypedValue<T>
impl<'a, T: FromValueOptional<'a> + SetValue> TypedValue<T>
Sourcepub fn get(&'a self) -> Option<T>
pub fn get(&'a self) -> Option<T>
Returns the value.
Types that don’t support a None value always return Some. See
get_some.
Sourcepub fn get_some(&'a self) -> Twhere
T: FromValue<'a>,
pub fn get_some(&'a self) -> Twhere
T: FromValue<'a>,
Returns the value.
This method is only available for types that don’t support a None
value.
Sourcepub fn set<U: ?Sized + SetValueOptional>(&mut self, value: Option<&U>)where
T: Borrow<U>,
pub fn set<U: ?Sized + SetValueOptional>(&mut self, value: Option<&U>)where
T: Borrow<U>,
Sets the value.
This method is only available for types that support a None value.
Sourcepub fn set_none(&mut self)where
T: SetValueOptional,
pub fn set_none(&mut self)where
T: SetValueOptional,
Sets the value to None.
This method is only available for types that support a None value.
Source§impl<'a, T: FromValueOptional<'a> + SetValue + Send> TypedValue<T>
impl<'a, T: FromValueOptional<'a> + SetValue + Send> TypedValue<T>
pub fn into_send_value(self) -> SendValue
Methods from Deref<Target = Value>§
Sourcepub fn downcast_ref<'a, T: FromValueOptional<'a> + SetValue>(
&self,
) -> Option<&TypedValue<T>>
pub fn downcast_ref<'a, T: FromValueOptional<'a> + SetValue>( &self, ) -> Option<&TypedValue<T>>
Tries to downcast to a &TypedValue.
Returns Some(&TypedValue<T>) if the value carries a type corresponding
to T and None otherwise.
Sourcepub fn get<'a, T: FromValueOptional<'a>>(&'a self) -> Option<T>
pub fn get<'a, T: FromValueOptional<'a>>(&'a self) -> Option<T>
Tries to get a value of type T.
Returns Some if the type is correct and the value is not None.
This function doesn’t distinguish between type mismatches and correctly
typed None values. Use downcast or is for that.
Sourcepub fn is<'a, T: FromValueOptional<'a> + SetValue>(&self) -> bool
pub fn is<'a, T: FromValueOptional<'a> + SetValue>(&self) -> bool
Returns true if the type of the value corresponds to T
or is a sub-type of T.
Trait Implementations§
Source§impl<T: Clone> Clone for TypedValue<T>
impl<T: Clone> Clone for TypedValue<T>
Source§fn clone(&self) -> TypedValue<T>
fn clone(&self) -> TypedValue<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more