pub struct MaybeUnset<T> { /* private fields */ }Expand description
Helper type for identifying whether a value was explicitly set or it is left default.
Implementations§
source§impl<T> MaybeUnset<T>
impl<T> MaybeUnset<T>
sourcepub fn new_or(default: T, value: Option<T>) -> Self
pub fn new_or(default: T, value: Option<T>) -> Self
Create a new value from an Option. If it is Some, the value is considered set with
the contained value. Otherwise it is considered unset with the default.
sourcepub fn try_set(&mut self, value: Option<T>)
pub fn try_set(&mut self, value: Option<T>)
Will set the value if value is Some. If value is None, the state of the object is unchanged.
sourcepub fn set_if_unset(&mut self, value: T) -> bool
pub fn set_if_unset(&mut self, value: T) -> bool
Only sets the value if the set flag is false.
Returns whether a new value was set.
sourcepub fn try_set_if_unset(&mut self, value: Option<T>) -> bool
pub fn try_set_if_unset(&mut self, value: Option<T>) -> bool
Only sets the value if the set flag is false and value is Some.
Returns whether a new value was set.
sourcepub fn unwrap(self) -> T
pub fn unwrap(self) -> T
Unwrap this value from the MaybeUnset wrapper. Never panics.
sourcepub fn map<U, P: FnOnce(T) -> U>(self, f: P) -> MaybeUnset<U>
pub fn map<U, P: FnOnce(T) -> U>(self, f: P) -> MaybeUnset<U>
Map this value using a function. The set flag is carried over.
source§impl<T: Clone> MaybeUnset<T>
impl<T: Clone> MaybeUnset<T>
sourcepub fn get_cloned(&self) -> T
pub fn get_cloned(&self) -> T
Clone the underlying value.
pub fn cloned(&self) -> Self
source§impl<T: Copy> MaybeUnset<T>
impl<T: Copy> MaybeUnset<T>
sourcepub fn get_copied(&self) -> T
pub fn get_copied(&self) -> T
Copy the underlying value.
pub fn copied(&self) -> Self
Trait Implementations§
source§impl<T> AsRef<T> for MaybeUnset<T>
impl<T> AsRef<T> for MaybeUnset<T>
source§impl<T: Clone> Clone for MaybeUnset<T>
impl<T: Clone> Clone for MaybeUnset<T>
source§fn clone(&self) -> MaybeUnset<T>
fn clone(&self) -> MaybeUnset<T>
Returns a copy of the value. Read more
1.6.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<T: Debug> Debug for MaybeUnset<T>
impl<T: Debug> Debug for MaybeUnset<T>
source§impl<T: Default> Default for MaybeUnset<T>
impl<T: Default> Default for MaybeUnset<T>
source§impl<T> Deref for MaybeUnset<T>
impl<T> Deref for MaybeUnset<T>
source§impl From<MaybeUnset<LineType>> for AssociatedData
impl From<MaybeUnset<LineType>> for AssociatedData
source§fn from(value: MaybeUnset<LineType>) -> Self
fn from(value: MaybeUnset<LineType>) -> Self
Converts to this type from the input type.
source§impl From<MaybeUnset<Style>> for AssociatedData
impl From<MaybeUnset<Style>> for AssociatedData
source§fn from(value: MaybeUnset<Style>) -> Self
fn from(value: MaybeUnset<Style>) -> Self
Converts to this type from the input type.
source§impl From<MaybeUnset<bool>> for AssociatedData
impl From<MaybeUnset<bool>> for AssociatedData
source§fn from(value: MaybeUnset<bool>) -> Self
fn from(value: MaybeUnset<bool>) -> Self
Converts to this type from the input type.
impl<T: Copy> Copy for MaybeUnset<T>
Auto Trait Implementations§
impl<T> Freeze for MaybeUnset<T>where
T: Freeze,
impl<T> RefUnwindSafe for MaybeUnset<T>where
T: RefUnwindSafe,
impl<T> Send for MaybeUnset<T>where
T: Send,
impl<T> Sync for MaybeUnset<T>where
T: Sync,
impl<T> Unpin for MaybeUnset<T>where
T: Unpin,
impl<T> UnwindSafe for MaybeUnset<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneWithNode for Twhere
T: Clone,
impl<T> CloneWithNode for Twhere
T: Clone,
source§fn clone_with_node(&mut self) -> T
fn clone_with_node(&mut self) -> T
Clone
self and take its node.source§fn clone_without_node(&self) -> T
fn clone_without_node(&self) -> T
Clone
self without taking its node.source§impl<T> Convert for T
impl<T> Convert for T
source§fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
Convert
self into a specific type. Read moresource§fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
Check if
self can be converted into a specific type. Read more