pub enum WithDefault<T> {
Some(T),
Default(T),
}
Variants§
Implementations§
Source§impl<T> WithDefault<T>
impl<T> WithDefault<T>
pub fn new_with_default(value: Option<T>, default: T) -> Self
Source§impl<T: ToOwned<Owned = T>> WithDefault<T>
impl<T: ToOwned<Owned = T>> WithDefault<T>
pub fn get_cloned_or_computed(&self) -> T
Source§impl<T: Clone> WithDefault<T>
impl<T: Clone> WithDefault<T>
pub fn get_ref_or_default(&self) -> Cow<'_, T>
Source§impl<T> WithDefault<T>
impl<T> WithDefault<T>
pub fn is_default(&self) -> bool
pub fn unwrap_or_default(self) -> T
Source§impl<T: Clone> WithDefault<T>
impl<T: Clone> WithDefault<T>
pub fn get_or_default(&self) -> T
Trait Implementations§
Source§impl<T: Clone> Clone for WithDefault<T>
impl<T: Clone> Clone for WithDefault<T>
Source§impl<T: Debug> Debug for WithDefault<T>
impl<T: Debug> Debug for WithDefault<T>
Source§impl<T> Default for WithDefault<T>where
T: Default,
impl<T> Default for WithDefault<T>where
T: Default,
Source§impl<'de, T> Deserialize<'de> for WithDefault<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for WithDefault<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
Source§impl<T> From<Option<T>> for WithDefault<T>where
WithDefault<T>: Default,
impl<T> From<Option<T>> for WithDefault<T>where
WithDefault<T>: Default,
Source§impl<T> From<T> for WithDefault<T>
impl<T> From<T> for WithDefault<T>
Source§impl<T> From<WithDefault<T>> for Option<T>
impl<T> From<WithDefault<T>> for Option<T>
Source§fn from(value: WithDefault<T>) -> Option<T>
fn from(value: WithDefault<T>) -> Option<T>
Converts to this type from the input type.
Source§impl<T: PartialEq> PartialEq for WithDefault<T>
impl<T: PartialEq> PartialEq for WithDefault<T>
Auto Trait Implementations§
impl<T> Freeze for WithDefault<T>where
T: Freeze,
impl<T> RefUnwindSafe for WithDefault<T>where
T: RefUnwindSafe,
impl<T> Send for WithDefault<T>where
T: Send,
impl<T> Sync for WithDefault<T>where
T: Sync,
impl<T> Unpin for WithDefault<T>where
T: Unpin,
impl<T> UnwindSafe for WithDefault<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