pub enum Override<T> {
No,
Clear,
Yes {
value: T,
},
}
Expand description
A Package
property that can override its respective defaults in PackageBase
.
This type is similar to Option
, which has special serialization behavior.
However, in some file formats (e.g. JSON) it is not possible to represent data such as
Option<Option<T>>
, as serialization would flatten the structure. This type enables
representation of this type of data.
Variants§
Implementations§
Source§impl<T> Override<T>
impl<T> Override<T>
Sourcepub fn merge_option(self, other: &mut Option<T>)
pub fn merge_option(self, other: &mut Option<T>)
Applies self
onto an Option<T>
.
Override::No
->other
stays untouched.Override::Clear
->other
is set toNone
.Override::Yes { value }
->other
is set toSome(value)
.
Sourcepub fn get_or_insert(&mut self, default: T) -> &mut T
pub fn get_or_insert(&mut self, default: T) -> &mut T
If Override::Yes
, its value will be returned.
If self
is something else, self
will be set to a Override::Yes { value: default }
.
Similar to as Option::get_or_insert.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Override<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Override<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Override<T>where
T: Freeze,
impl<T> RefUnwindSafe for Override<T>where
T: RefUnwindSafe,
impl<T> Send for Override<T>where
T: Send,
impl<T> Sync for Override<T>where
T: Sync,
impl<T> Unpin for Override<T>where
T: Unpin,
impl<T> UnwindSafe for Override<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