pub enum FeatureState<T> {
Enabled(T),
Disabled,
}Expand description
Whether an optional TOML section is present and active.
load_optional_section returns Enabled(T) when the key exists in any
config file and Disabled when it is absent from all of them.
Variants§
Enabled(T)
The section key is present in TOML and deserialized successfully into T.
Disabled
The section key is absent from every config file – the feature is off.
Trait Implementations§
Source§impl<T: Clone> Clone for FeatureState<T>
impl<T: Clone> Clone for FeatureState<T>
Source§impl<T: Debug> Debug for FeatureState<T>
impl<T: Debug> Debug for FeatureState<T>
Source§impl<T> FeatureStateOps for FeatureState<T>
impl<T> FeatureStateOps for FeatureState<T>
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Return
true when the state holds an enabled value.Source§fn is_disabled(&self) -> bool
fn is_disabled(&self) -> bool
Return
true when the state is disabled.Source§fn into_option(self) -> Option<Self::Value>
fn into_option(self) -> Option<Self::Value>
Convert into an
Option<Self::Value>, discarding disabled states.Source§fn map<U>(self, f: impl FnOnce(Self::Value) -> U) -> FeatureState<U>
fn map<U>(self, f: impl FnOnce(Self::Value) -> U) -> FeatureState<U>
Map the inner value when enabled.
Source§fn and_then<U>(
self,
f: impl FnOnce(Self::Value) -> FeatureState<U>,
) -> FeatureState<U>
fn and_then<U>( self, f: impl FnOnce(Self::Value) -> FeatureState<U>, ) -> FeatureState<U>
Chain another state-producing operation when enabled.
Source§fn unwrap_or(self, default: Self::Value) -> Self::Value
fn unwrap_or(self, default: Self::Value) -> Self::Value
Return the inner value or the provided default when disabled.
Source§impl<T> From<FeatureState<T>> for Option<T>
impl<T> From<FeatureState<T>> for Option<T>
Source§fn from(state: FeatureState<T>) -> Self
fn from(state: FeatureState<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<Option<T>> for FeatureState<T>
impl<T> From<Option<T>> for FeatureState<T>
Auto Trait Implementations§
impl<T> Forget for FeatureState<T>
impl<T> Freeze for FeatureState<T>where
T: Freeze,
impl<T> RefUnwindSafe for FeatureState<T>where
T: RefUnwindSafe,
impl<T> Send for FeatureState<T>where
T: Send,
impl<T> Sync for FeatureState<T>where
T: Sync,
impl<T> Unpin for FeatureState<T>where
T: Unpin,
impl<T> UnsafeUnpin for FeatureState<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for FeatureState<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