Expand description
A dynamically-sized view into individual bits of a memory region.
You can read the language’s slice module documentation here.
This module defines the BitSlice region, and all of its associated support
code.
BitSlice is the primary working type of this crate. It is a wrapper type over
[T] which enables you to view, manipulate, and take the address of individual
bits in memory. It behaves in every possible respect exactly like an ordinary
slice: it is dynamically-sized, and must be held by & or &mut reference,
just like [T], and implements every inherent method and trait that [T] does,
to the absolute limits of what Rust permits.
The key to BitSlice’s powerful capability is that references to it use a
special encoding that store, in addition to the address of the base element and
the bit length, the index of the starting bit in the base element. This custom
reference encoding has some costs in what APIs are possible – for instance, Rust
forbids it from supporting &mut BitSlice[index] = bool write indexing – but in
exchange, enables it to be far more capable than any other bit-slice crate in
existence.
Because of the volume of code that must be written to match the [T] standard
API, this module is organized very differently than the slice implementation in
the core and std distribution libraries.
- the root module
slicecontains new APIs that have no counterpart in[T] slice/apicontains reïmplementations of the[T]inherent methodsslice/iterimplements all of the iteration capabilityslice/opsimplements the traits incore::opsslice/proxyimplements the proxy reference used in place of&mut boolslice/traitsimplements all other traits not incore::ops- lastly,
slice/testscontains all the unit tests.
!
Structs
Proxy reference type, equivalent to &mut bool.
A slice of individual bits, anywhere in memory.
An iterator over a bit slice in (non-overlapping) chunks (chunk_size bits
at a time), starting at the beginning of the slice.
An iterator over a bit slice in (non-overlapping) chunks (chunk_size bits
at a time), starting at the beginning of the slice.
An iterator over a bit slice in (non-overlapping) mutable chunks
(chunk_size bits at a time), starting at the beginning of the slice.
An iterator over a bit slice in (non-overlapping) mutable chunks
(chunk_size bits at a time), starting at the beginning of the slice.
Immutable slice iterator
Mutable bit slice iterator.
An iterator over a bit slice in (non-overlapping) chunks (chunk_size bits
at a time), starting at the end of the slice.
An iterator over a bit slice in (non-overlapping) chunks (chunk_size bits
at a time), starting at the end of the slice.
An iterator over a bit slice in (non-overlapping) mutable chunks
(chunk_size bits at a time), starting at the end of the slice.
An iterator over a slice in (non-overlapping) mutable chunks (chunk_size
bits at a time), starting at the end of the slice.
An iterator over subslices separated by bits that match a predicate function, starting from the end of the slice.
An iterator over subslices separated by bits that match a predicate function, starting from the end of the slice.
An iterator over subslices separated by bits that match a predicate function, limited to a given number of splits, starting from the end of the slice.
An iterator over subslices separated by bits that match a predicate function, limited to a given number of splits, starting from the end of the slice.
An iterator over subslices separated by bits that match a predicate function.
An iterator over the mutable subslices of the slice which are separated by
bits that match pred.
An iterator over subslices separated by bits that match a predicate function, limited to a given number of splits.
An iterator over subslices separated by bits that match a predicate function, limited to a given number of splits.
An iterator over overlapping subslices of length size.
Traits
A helper trait used for indexing operations.
Functions
Constructs a &BitSlice reference from its component data.
Constructs a &mut BitSlice reference from its component data.
Converts a reference to T into a bitslice over one element.
Forms a bitslice from a pointer and a length.
Performs the same functionality as from_raw_parts, except that a mutable
bitslice is returned.
Converts a reference to T into a bitslice over one element.
