Skip to main content

FeatureState

Enum FeatureState 

Source
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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for FeatureState<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> FeatureStateOps for FeatureState<T>

Source§

type Value = T

The inner value type when the state is enabled.
Source§

fn is_enabled(&self) -> bool

Return true when the state holds an enabled value.
Source§

fn is_disabled(&self) -> bool

Return true when the state is disabled.
Source§

fn into_option(self) -> Option<Self::Value>

Convert into an Option<Self::Value>, discarding disabled states.
Source§

fn as_option(&self) -> Option<&Self::Value>

Borrow the inner value when enabled.
Source§

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>

Chain another state-producing operation when enabled.
Source§

fn unwrap_or(self, default: Self::Value) -> Self::Value

Return the inner value or the provided default when disabled.
Source§

fn unwrap_or_else(self, f: impl FnOnce() -> Self::Value) -> Self::Value

Return the inner value or compute one lazily when disabled.
Source§

fn enabled_or_default(self) -> Self::Value
where Self::Value: Default,

Return the enabled value or Self::Value::default() when disabled.
Source§

impl<T> From<FeatureState<T>> for Option<T>

Source§

fn from(state: FeatureState<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Option<T>> for FeatureState<T>

Source§

fn from(opt: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for FeatureState<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.