Module bitvec::view [−][src]
Expand description
View constructors for memory regions.
The &BitSlice
type is a referential view over existing memory. The inherent
constructors are awkward to call, as they require function syntax rather than
method syntax, and must provide a token for the memory type even though this is
provided by the prior binding.
This module provides a view trait, ViewBits
, which provides BitSlice
constructors available in method-call syntax with only ordering type parameters.
In addition, the traits AsBits
and AsBitsMut
are analogues of AsRef
and
AsMut
, respectively. These traits have a blanket implementation for all
A: As{Ref,Mut}<[T: BitStore]>
, so that any type that implements a view to a
suitable memory region automatically implements a view to that region’s bits.
These traits are distinct because ViewBits
combines the im/mutable view
functions into one trait, and can provide specialized implementations with a
slight performance increase over the generic, but AsBits{,Mut}
can fit in the
generic type system of any library without undue effort.