pub trait BitView {
type Store: BitStore;
fn view_bits<O>(&self) -> &BitSlice<O, Self::Store>ⓘ
where
O: BitOrder;
fn view_bits_mut<O>(&mut self) -> &mut BitSlice<O, Self::Store>ⓘ
where
O: BitOrder;
}
Expand description
Creates a BitSlice
view over some type that supports it.
This trait is implemented on all BitRegister
types, and the arrays and slices
of them that are supported by the standard library.
This means that until type-level integers are stabilized, only arrays in
[T: BitRegister; 0 ..= 64]
will implement the trait; wider arrays will need to
reborrow as slices [T]
in order to use the slice implementation.
If you have a type that contains a BitRegister
type that can be viewed with
this trait, then you can implement this trait by forwarding to the interior
view.
Associated Types
Required methods
Views a memory region as a BitSlice
.
Type Parameters
O
: The bit ordering used for the region.
Parameters
&self
: The region to view as individual bits.
Returns
A &BitSlice
view over the region at *self
.
fn view_bits_mut<O>(&mut self) -> &mut BitSlice<O, Self::Store>ⓘ where
O: BitOrder,
fn view_bits_mut<O>(&mut self) -> &mut BitSlice<O, Self::Store>ⓘ where
O: BitOrder,
Views a memory region as a mutable BitSlice
.
Type Parameters
O
: The bit ordering used for the region.
Parameters
&mut self
: The region to view as individual mutable bits.
Returns
A &mut BitSlice
view over the region at *self
.