Trait BitField

Source
pub trait BitField<T> {
    // Required methods
    fn set_bit(&mut self, i: T);
    fn clear_bit(&mut self, i: T);
    fn toggle_bit(&mut self, i: T);
    fn get_bit(&self, i: T) -> bool;
    fn set_bit_range(&mut self, range: RangeInclusive<T>, b: T);
    fn get_bit_range(&self, range: RangeInclusive<T>) -> T;
}
Expand description

Defines methods for bit-field manipulation

Required Methods§

Source

fn set_bit(&mut self, i: T)

Sets the i’th bit to 1

Source

fn clear_bit(&mut self, i: T)

Clears the i’th bit to 0

Source

fn toggle_bit(&mut self, i: T)

Toggles the i’th bit

Source

fn get_bit(&self, i: T) -> bool

Gets the i’th bit.

true for 1 false for 0

Source

fn set_bit_range(&mut self, range: RangeInclusive<T>, b: T)

Sets bits in the given range to b

Source

fn get_bit_range(&self, range: RangeInclusive<T>) -> T

Gets the bits in the given range

Implementors§

Source§

impl<T> BitField<T> for T
where T: BitOrAssign<T> + BitXorAssign<T> + Shl<T, Output = T> + Shr<T, Output = T> + BitAnd<T, Output = Self> + BitAndAssign<T> + Sub<T, Output = Self> + Add<T, Output = Self> + Not<Output = Self> + From<u8> + PartialEq<T> + Default + Copy,