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§
Required Methods§
Sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Return true when the state holds an enabled value.
Sourcefn is_disabled(&self) -> bool
fn is_disabled(&self) -> bool
Return true when the state is disabled.
Sourcefn into_option(self) -> Option<Self::Value>
fn into_option(self) -> Option<Self::Value>
Convert into an Option<Self::Value>, discarding disabled states.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn unwrap_or_else(self, f: impl FnOnce() -> Self::Value) -> Self::Value
fn unwrap_or_else(self, f: impl FnOnce() -> Self::Value) -> Self::Value
Return the inner value or compute one lazily when disabled.
Sourcefn enabled_or_default(self) -> Self::Value
fn enabled_or_default(self) -> Self::Value
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".