Struct LayerBitset
pub struct LayerBitset(/* private fields */);Expand description
Fixed-capacity bitset of layers for modifier / conditional-layer state.
Bit i corresponds to layer index i.
Capacity is Self::BITS layers (indices 0..=[MAX_BITSET_LAYER]).
This is a thin no_std newtype over u32
so keymap const data can build bitsets
without a heap or an external bitset crate.
Widening capacity later is a storage-type change (u64, u128, or multi-limb)
behind the same API.
Implementations§
§impl LayerBitset
impl LayerBitset
pub const EMPTY: LayerBitset
pub const EMPTY: LayerBitset
Empty bitset (no layers selected).
pub const ALL: LayerBitset
pub const ALL: LayerBitset
Bitset with every representable layer bit set.
pub const fn from_bits(bits: u32) -> LayerBitset
pub const fn from_bits(bits: u32) -> LayerBitset
Construct from raw bits (bit i = layer i).
pub const fn insert(self, index: usize) -> LayerBitset
pub const fn insert(self, index: usize) -> LayerBitset
Returns a copy with bit index set, if index is in range.
pub const fn remove(self, index: usize) -> LayerBitset
pub const fn remove(self, index: usize) -> LayerBitset
Returns a copy with bit index cleared, if index is in range.
pub const fn is_superset_of(self, other: LayerBitset) -> bool
pub const fn is_superset_of(self, other: LayerBitset) -> bool
Returns true if every bit set in other is also set in self.
Trait Implementations§
§impl BitAnd for LayerBitset
impl BitAnd for LayerBitset
§type Output = LayerBitset
type Output = LayerBitset
The resulting type after applying the
& operator.§fn bitand(self, rhs: LayerBitset) -> <LayerBitset as BitAnd>::Output
fn bitand(self, rhs: LayerBitset) -> <LayerBitset as BitAnd>::Output
Performs the
& operation. Read more§impl BitOr for LayerBitset
impl BitOr for LayerBitset
§type Output = LayerBitset
type Output = LayerBitset
The resulting type after applying the
| operator.§fn bitor(self, rhs: LayerBitset) -> <LayerBitset as BitOr>::Output
fn bitor(self, rhs: LayerBitset) -> <LayerBitset as BitOr>::Output
Performs the
| operation. Read more§impl Clone for LayerBitset
impl Clone for LayerBitset
§fn clone(&self) -> LayerBitset
fn clone(&self) -> LayerBitset
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for LayerBitset
§impl Debug for LayerBitset
impl Debug for LayerBitset
§impl Default for LayerBitset
impl Default for LayerBitset
§fn default() -> LayerBitset
fn default() -> LayerBitset
Returns the “default value” for a type. Read more
§impl<'de> Deserialize<'de> for LayerBitset
impl<'de> Deserialize<'de> for LayerBitset
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayerBitset, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayerBitset, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for LayerBitset
§impl From<u32> for LayerBitset
impl From<u32> for LayerBitset
§fn from(bits: u32) -> LayerBitset
fn from(bits: u32) -> LayerBitset
Converts to this type from the input type.
§impl Not for LayerBitset
impl Not for LayerBitset
§type Output = LayerBitset
type Output = LayerBitset
The resulting type after applying the
! operator.§impl PartialEq for LayerBitset
impl PartialEq for LayerBitset
impl StructuralPartialEq for LayerBitset
Auto Trait Implementations§
impl Freeze for LayerBitset
impl RefUnwindSafe for LayerBitset
impl Send for LayerBitset
impl Sync for LayerBitset
impl Unpin for LayerBitset
impl UnsafeUnpin for LayerBitset
impl UnwindSafe for LayerBitset
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