pub struct FeatureMask<const N_FEATURES: usize> { /* private fields */ }Expand description
Type-safe feature mask with const generic size
Implementations§
Source§impl<const N_FEATURES: usize> FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> FeatureMask<N_FEATURES>
Sourcepub const fn all_selected() -> Self
pub const fn all_selected() -> Self
Create a new feature mask with all features selected
Sourcepub const fn none_selected() -> Self
pub const fn none_selected() -> Self
Create a new feature mask with no features selected
Sourcepub const fn from_array(mask: [bool; N_FEATURES]) -> Self
pub const fn from_array(mask: [bool; N_FEATURES]) -> Self
Create a feature mask from a boolean array
Sourcepub fn from_indices(indices: &[FeatureIndex<N_FEATURES>]) -> Self
pub fn from_indices(indices: &[FeatureIndex<N_FEATURES>]) -> Self
Create a feature mask from selected indices
Sourcepub const fn as_array(&self) -> &[bool; N_FEATURES]
pub const fn as_array(&self) -> &[bool; N_FEATURES]
Get the mask as a boolean array
Sourcepub const fn is_selected(&self, index: FeatureIndex<N_FEATURES>) -> bool
pub const fn is_selected(&self, index: FeatureIndex<N_FEATURES>) -> bool
Check if a feature is selected
Sourcepub fn set(&mut self, index: FeatureIndex<N_FEATURES>, selected: bool)
pub fn set(&mut self, index: FeatureIndex<N_FEATURES>, selected: bool)
Set a feature as selected or unselected
Sourcepub fn count_selected(&self) -> usize
pub fn count_selected(&self) -> usize
Get the number of selected features
Sourcepub fn selected_indices(&self) -> Vec<FeatureIndex<N_FEATURES>>
pub fn selected_indices(&self) -> Vec<FeatureIndex<N_FEATURES>>
Get indices of selected features
Trait Implementations§
Source§impl<const N_FEATURES: usize> Clone for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> Clone for FeatureMask<N_FEATURES>
Source§fn clone(&self) -> FeatureMask<N_FEATURES>
fn clone(&self) -> FeatureMask<N_FEATURES>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const N_FEATURES: usize> Debug for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> Debug for FeatureMask<N_FEATURES>
Source§impl<const N: usize> ZeroCostTransform<FeatureMask<N>, Vec<bool>> for ()
Zero-cost feature mask conversion
impl<const N: usize> ZeroCostTransform<FeatureMask<N>, Vec<bool>> for ()
Zero-cost feature mask conversion
Source§fn transform_zero_cost(input: FeatureMask<N>) -> Vec<bool>
fn transform_zero_cost(input: FeatureMask<N>) -> Vec<bool>
Apply the transformation with zero runtime cost
Auto Trait Implementations§
impl<const N_FEATURES: usize> Freeze for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> RefUnwindSafe for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> Send for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> Sync for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> Unpin for FeatureMask<N_FEATURES>
impl<const N_FEATURES: usize> UnwindSafe for FeatureMask<N_FEATURES>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.