Skip to main content

FeatureStateOps

Trait FeatureStateOps 

Source
pub trait FeatureStateOps: Sized {
    type Value;

    // Required methods
    fn is_enabled(&self) -> bool;
    fn is_disabled(&self) -> bool;
    fn into_option(self) -> Option<Self::Value>;
    fn as_option(&self) -> Option<&Self::Value>;
    fn map<U>(self, f: impl FnOnce(Self::Value) -> U) -> FeatureState<U>;
    fn and_then<U>(
        self,
        f: impl FnOnce(Self::Value) -> FeatureState<U>,
    ) -> FeatureState<U>;
    fn unwrap_or(self, default: Self::Value) -> Self::Value;
    fn unwrap_or_else(self, f: impl FnOnce() -> Self::Value) -> Self::Value;
    fn enabled_or_default(self) -> Self::Value
       where Self::Value: Default;
}
Expand description

Operations on FeatureState<T> — presence-driven feature gate.

Required Associated Types§

Source

type Value

The inner value type when the state is enabled.

Required Methods§

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§