Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
# Shared Bit-Slice Chunking
This iterator yields successive non-overlapping chunks of a bit-slice. Chunking
advances one subslice at a time, starting at the beginning of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the final chunk will be the remainder, and will be shorter than requested.
It is created by the [`BitSlice::chunks`] method.
## Original
[`slice::Chunks`](core::slice::Chunks)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut chunks = bits.chunks(3);
assert_eq!(chunks.next().unwrap(), bits![0; 3]);
assert_eq!(chunks.next().unwrap(), bits![1; 3]);
assert_eq!(chunks.next().unwrap(), bits![0, 1]);
assert!(chunks.next().is_none());
```
[`BitSlice::chunks`]: crate::slice::BitSlice::chunks
@@ -0,0 +1,31 @@
# Shared Bit-Slice Exact Chunking
This iterator yields successive non-overlapping chunks of a bit-slice. Chunking
advances one sub-slice at a time, starting at the beginning of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the leftover segment at the back is not iterated, but can be accessed with
the [`.remainder()`] method.
It is created by the [`BitSlice::chunks_exact`] method.
## Original
[`slice::ChunksExact`](core::slice::ChunksExact)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut chunks = bits.chunks_exact(3);
assert_eq!(chunks.next().unwrap(), bits![0; 3]);
assert_eq!(chunks.next().unwrap(), bits![1; 3]);
assert!(chunks.next().is_none());
assert_eq!(chunks.remainder(), bits![0, 1]);
```
[`BitSlice::chunks_exact`]: crate::slice::BitSlice::chunks_exact
[`.remainder()`]: Self::remainder
@@ -0,0 +1,42 @@
# Exclusive Bit-Slice Exact Chunking
This iterator yields successive non-overlapping mutable chunks of a bit-slice.
Chunking advances one sub-slice at a time, starting at the beginning of the
bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the leftover segment at the back is not iterated, but can be accessed with
the [`.into_remainder()`] or [`.take_remainder()`] methods.
It is created by the [`BitSlice::chunks_exact_mut`] method.
## Original
[`slice::ChunksExactMut`](core::slice::ChunksExactMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut chunks = unsafe {
bits.chunks_exact_mut(3).remove_alias()
};
chunks.next().unwrap().fill(true);
chunks.next().unwrap().fill(false);
assert!(chunks.next().is_none());
chunks.take_remainder().copy_from_bitslice(bits![1, 0]);
assert!(chunks.take_remainder().is_empty());
assert_eq!(bits, bits![1, 1, 1, 0, 0, 0, 1, 0]);
```
[`BitSlice::chunks_exact_mut`]: crate::slice::BitSlice::chunks_exact_mut
[`.into_remainder()`]: Self::into_remainder
[`.take_remainder()`]: Self::take_remainder
+38
View File
@@ -0,0 +1,38 @@
# Exclusive Bit-Slice Chunking
This iterator yields successive non-overlapping mutable chunks of a bit-slice.
Chunking advances one subslice at a time, starting at the beginning of the
bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the final chunk will be the remainder, and will be shorter than requested.
It is created by the [`BitSlice::chunks_mut`] method.
## Original
[`slice::ChunksMut`](core::slice::ChunksMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut chunks = unsafe {
bits.chunks_mut(3).remove_alias()
};
chunks.next().unwrap().fill(true);
chunks.next().unwrap().fill(false);
chunks.next().unwrap().copy_from_bitslice(bits![1, 0]);
assert!(chunks.next().is_none());
assert_eq!(bits, bits![1, 1, 1, 0, 0, 0, 1, 0]);
```
[`BitSlice::chunks_mut`]: crate::slice::BitSlice::chunks_mut
+36
View File
@@ -0,0 +1,36 @@
# Shared Bit-Slice Iteration
This view iterates each bit in the bit-slice by [proxy reference][0]. It is
created by the [`BitSlice::iter`] method.
## Original
[`slice::Iter`](core::slice::Iter)
## API Differences
While this iterator can manifest `&bool` references, it instead yields the
`bitvec` [proxy reference][0] for consistency with the [`IterMut`] type. It can
be converted to yield true references with [`.by_refs()`]. Additionally, because
it does not yield `&bool`, the [`Iterator::copied`] method does not apply. It
can be converted to an iterator of `bool` values with [`.by_vals()`].
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 1];
for bit in bits.iter() {
# #[cfg(feature = "std")] {
println!("{}", bit);
# }
}
```
[`BitSlice::iter`]: crate::slice::BitSlice::iter
[`IterMut`]: crate::slice::IterMut
[`Iterator::copied`]: core::iter::Iterator::copied
[`.by_refs()`]: Self::by_refs
[`.by_vals()`]: Self::by_vals
[0]: crate::ptr::BitRef
+30
View File
@@ -0,0 +1,30 @@
# Exclusive Bit-Slice Iteration
This view iterates each bit in the bit-slice by exclusive proxy reference. It is
created by the [`BitSlice::iter_mut`] method.
## Original
[`slice::IterMut`](core::slice::IterMut)
## API Differences
Because `bitvec` cannot manifest `&mut bool` references, this instead yields the
crate [proxy reference][0]. Because the proxy is a true type, rather than an
`&mut` reference, its name must be bound with `mut` in order to write through
it.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 1];
for mut bit in bits.iter_mut() {
*bit = !*bit;
}
assert_eq!(bits, bits![1, 0]);
```
[`BitSlice::iter_mut`]: crate::slice::BitSlice::iter_mut
[0]: crate::ptr::BitRef
+23
View File
@@ -0,0 +1,23 @@
# Bit Seeking
This iterator yields indices of bits set to `1`, rather than bit-values
themselves. It is essentially the inverse of indexing: rather than applying a
`usize` to the bit-slice to get a `bool`, this applies a `bool` to get a
`usize`.
It is created by the [`.iter_ones()`] method on bit-slices.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 1, 0, 0, 1];
let mut ones = bits.iter_ones();
assert_eq!(ones.next(), Some(1));
assert_eq!(ones.next(), Some(4));
assert!(ones.next().is_none());
```
[`.iter_ones()`]: crate::slice::BitSlice::iter_ones
+23
View File
@@ -0,0 +1,23 @@
# Bit Seeking
This iterator yields indices of bits cleared to `0`, rather than bit-values
themselves. It is essentially the inverse of indexing: rather than applying a
`usize` to the bit-slice to get a `bool`, this applies a `bool` to get a
`usize`.
It is created by the [`.iter_zeros()`] method on bit-slices.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![1, 0, 1, 1, 0];
let mut zeros = bits.iter_zeros();
assert_eq!(zeros.next(), Some(1));
assert_eq!(zeros.next(), Some(4));
assert!(zeros.next().is_none());
```
[`.iter_zeros()`]: crate::slice::BitSlice::iter_zeros
+103
View File
@@ -0,0 +1,103 @@
# Anti-Aliasing Iterator Adapter
This structure is an adapter over a corresponding `&mut BitSlice` iterator. It
removes the `::Alias` taint marker, allowing mutations through each yielded bit
reference to skip any costs associated with aliasing.
## Safety
The default `&mut BitSlice` iterators attach an `::Alias` taint for a reason:
the iterator protocol does not mandate that yielded items have a narrower
lifespan than the iterator that produced them! As such, it is completely
possible to pull multiple yielded items out into the same scope, where they have
overlapping lifetimes.
The `BitStore` principles require that whenever two write-capable handles to the
same memory region have overlapping lifetimes, they *must* be `::Alias` tainted.
This adapter removes the `::Alias` taint, but is not able to enforce strictly
non-overlapping lifetimes of yielded items.
As such, this adapter is **unsafe to construct**, and you **must** only use it
in a `for`-loop where each yielded item does not escape the loop body.
In order to help enforce this limitation, this adapter structure is *not* `Send`
or `Sync`. It must be consumed in the scope where it was created.
## Usage
If you are using a loop that satisfies the safety requirement, you can use the
`.remove_alias()` method on your mutable iterator and configure it to yield
handles that do not impose additional alias-protection costs when accessing the
underlying memory.
Note that this adapter does not go to `T::Unalias`: it only takes an iterator
that yields `T::Alias` and unwinds it to `T`. If the source bit-slice was
*already* alias-tainted, the original protection is not removed. You are
responsible for doing so by using [`.bit_domain_mut()`].
## Examples
This example shows using `.chunks_mut()` without incurring alias protection.
This documentation is replicated on all `NoAlias` types; the examples will work
for all of them, but are not specialized in the text.
```rust
use bitvec::prelude::*;
use bitvec::slice::{ChunksMut, ChunksMutNoAlias};
type Alias8 = <u8 as BitStore>::Alias;
let mut data: BitArr!(for 40, in u8, Msb0) = bitarr![u8, Msb0; 0; 40];
let mut chunks: ChunksMut<u8, Msb0> = data.chunks_mut(5);
let _chunk: &mut BitSlice<Alias8, Msb0> = chunks.next().unwrap();
let mut chunks: ChunksMutNoAlias<u8, Msb0> = unsafe { chunks.remove_alias() };
let _chunk: &mut BitSlice<u8, Msb0> = chunks.next().unwrap();
```
This example shows how use of [`.split_at_mut()`] forces the `.remove_alias()` to
still retain a layer of alias protection.
```rust
use bitvec::prelude::*;
use bitvec::slice::{ChunksMut, ChunksMutNoAlias};
type Alias8 = <u8 as BitStore>::Alias;
type Alias8Alias = <Alias8 as BitStore>::Alias;
let mut data: BitArr!(for 40, in u8, Msb0) = bitarr!(u8, Msb0; 0; 40);
let (_head, rest): (_, &mut BitSlice<Alias8, Msb0>) = data.split_at_mut(5);
let mut chunks: ChunksMut<Alias8, Msb0> = rest.chunks_mut(5);
let _chunk: &mut BitSlice<Alias8, Msb0> = chunks.next().unwrap();
let mut chunks: ChunksMutNoAlias<Alias8, Msb0> = unsafe { chunks.remove_alias() };
let _chunk: &mut BitSlice<Alias8, Msb0> = chunks.next().unwrap();
```
And this example shows how to use `.bit_domain_mut()` in order to undo the
effects of `.split_at_mut()`, so that `.remove_alias()` can complete its work.
```rust
use bitvec::prelude::*;
use bitvec::slice::{ChunksMut, ChunksMutNoAlias};
type Alias8 = <u8 as BitStore>::Alias;
let mut data: BitArr!(for 40, in u8, Msb0) = bitarr!(u8, Msb0; 0; 40);
let (_head, rest): (_, &mut BitSlice<Alias8, Msb0>) = data.split_at_mut(5);
let (head, body, tail): (
&mut BitSlice<Alias8, Msb0>,
&mut BitSlice<u8, Msb0>,
&mut BitSlice<Alias8, Msb0>,
) = rest.bit_domain_mut().region().unwrap();
let mut chunks: ChunksMut<u8, Msb0> = body.chunks_mut(5);
let _chunk: &mut BitSlice<Alias8, Msb0> = chunks.next().unwrap();
let mut chunks: ChunksMutNoAlias<u8, Msb0> = unsafe { chunks.remove_alias() };
let _chunk: &mut BitSlice<u8, Msb0> = chunks.next().unwrap();
```
[`.bit_domain_mut()`]: crate::slice::BitSlice::bit_domain_mut
[`.split_at_mut()`]: crate::slice::BitSlice::split_at_mut
+29
View File
@@ -0,0 +1,29 @@
# Shared Bit-Slice Reverse Chunking
This iterator yields successive non-overlapping chunks of a bit-slice. Chunking
advances one subslice at a time, starting at the end of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the final chunk will be the remainder, and will be shorter than requested.
It is created by the [`BitSlice::rchunks`] method.
## Original
[`slice::RChunks`](core::slice::RChunks)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 1, 0, 0, 0, 1, 1, 1];
let mut chunks = bits.rchunks(3);
assert_eq!(chunks.next().unwrap(), bits![1; 3]);
assert_eq!(chunks.next().unwrap(), bits![0; 3]);
assert_eq!(chunks.next().unwrap(), bits![0, 1]);
assert!(chunks.next().is_none());
```
[`BitSlice::rchunks`]: crate::slice::BitSlice::rchunks
@@ -0,0 +1,31 @@
# Shared Bit-Slice Reverse Exact Chunking
This iterator yields successive non-overlapping chunks of a bit-slice. Chunking
advances one sub-slice at a time, starting at the end of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the leftover segment at the front is not iterated, but can be accessed with
the [`.remainder()`] method.
It is created by the [`BitSlice::rchunks_exact`] method.
## Original
[`slice::RChunksExact`](core::slice::RChunksExact)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 1, 0, 0, 0, 1, 1, 1];
let mut chunks = bits.rchunks_exact(3);
assert_eq!(chunks.next().unwrap(), bits![1; 3]);
assert_eq!(chunks.next().unwrap(), bits![0; 3]);
assert!(chunks.next().is_none());
assert_eq!(chunks.remainder(), bits![0, 1]);
```
[`BitSlice::rchunks_exact`]: crate::slice::BitSlice::rchunks_exact
[`.remainder()`]: Self::remainder
@@ -0,0 +1,41 @@
# Exclusive Bit-Slice Reverse Exact Chunking
This iterator yields successive non-overlapping mutable chunks of a bit-slice.
Chunking advances one sub-slice at a time, starting at the end of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the leftover segment at the front is not iterated, but can be accessed with
the [`.into_remainder()`] or [`.take_remainder()`] methods.
It is created by the [`BitSlice::rchunks_exact_mut`] method.
## Original
[`slice::RChunksExactMut`](core::slice::RChunksExactMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 1, 0, 0, 0, 1, 1, 1];
let mut chunks = unsafe {
bits.rchunks_exact_mut(3).remove_alias()
};
chunks.next().unwrap().fill(false);
chunks.next().unwrap().fill(true);
assert!(chunks.next().is_none());
chunks.take_remainder().copy_from_bitslice(bits![1, 0]);
assert!(chunks.take_remainder().is_empty());
assert_eq!(bits, bits![1, 0, 1, 1, 1, 0, 0, 0]);
```
[`BitSlice::rchunks_exact_mut`]: crate::slice::BitSlice::rchunks_exact_mut
[`.into_remainder()`]: Self::into_remainder
[`.take_remainder()`]: Self::take_remainder
@@ -0,0 +1,37 @@
# Exclusive Bit-Slice Chunking
This iterator yields successive non-overlapping mutable chunks of a bit-slice.
Chunking advances one subslice at a time, starting at the end of the bit-slice.
If the original bit-slices length is not evenly divided by the chunk width,
then the final chunk will be the remainder, and will be shorter than requested.
It is created by the [`BitSlice::chunks_mut`] method.
## Original
[`slice::ChunksMut`](core::slice::ChunksMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 1, 0, 0, 0, 1, 1, 1];
let mut chunks = unsafe {
bits.rchunks_mut(3).remove_alias()
};
chunks.next().unwrap().fill(false);
chunks.next().unwrap().fill(true);
chunks.next().unwrap().copy_from_bitslice(bits![1, 0]);
assert!(chunks.next().is_none());
assert_eq!(bits, bits![1, 0, 1, 1, 1, 0, 0, 0]);
```
[`BitSlice::chunks_mut`]: crate::slice::BitSlice::chunks_mut
+35
View File
@@ -0,0 +1,35 @@
# Shared Bit-Slice Reverse Splitting
This iterator yields successive non-overlapping segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the end of the bit-slice.
The matched bit is **not** included in the yielded segment.
It is created by the [`BitSlice::rsplit`] method.
## Original
[`slice::RSplit`](core::slice::RSplit)
## API Differences
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.rsplit(|idx, _bit| idx % 3 == 2);
assert_eq!(split.next().unwrap(), bits![0, 1]);
assert_eq!(split.next().unwrap(), bits![1; 2]);
assert_eq!(split.next().unwrap(), bits![0; 2]);
assert!(split.next().is_none());
```
[`BitSlice::rsplit`]: crate::slice::BitSlice::rsplit
+41
View File
@@ -0,0 +1,41 @@
# Exclusive Bit-Slice Reverse Splitting
This iterator yields successive non-overlapping mutable segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the end of the bit-slice.
The matched bit is **not** included in the yielded segment.
It is created by the [`BitSlice::rsplit_mut`] method.
## Original
[`slice::RSplitMut`](core::slice::RSplitMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut split = unsafe {
bits.rsplit_mut(|idx, _bit| idx % 3 == 2).remove_alias()
};
split.next().unwrap().copy_from_bitslice(bits![1, 0]);
split.next().unwrap().fill(false);
split.next().unwrap().fill(true);
assert!(split.next().is_none());
assert_eq!(bits, bits![1, 1, 0, 0, 0, 1, 1, 0]);
```
[`BitSlice::rsplit_mut`]: crate::slice::BitSlice::rsplit_mut
+36
View File
@@ -0,0 +1,36 @@
# Shared Bit-Slice Reverse Splitting
This iterator yields `n` successive non-overlapping segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the end of the bit-slice.
The matched bit is **not** included in the yielded segment. The `n`th yielded
segment does not attempt any further splits, and extends to the front of the
bit-slice.
It is created by the [`BitSlice::rsplitn`] method.
## Original
[`slice::RSplitN`](core::slice::RSplitN)
## API Differences
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.rsplitn(2, |idx, _bit| idx % 3 == 2);
assert_eq!(split.next().unwrap(), bits![0, 1]);
assert_eq!(split.next().unwrap(), bits![0, 0, 0, 1, 1]);
assert!(split.next().is_none());
```
[`BitSlice::rsplitn`]: crate::slice::BitSlice::rsplitn
@@ -0,0 +1,40 @@
# Exclusive Bit-Slice Reverse Splitting
This iterator yields `n` successive non-overlapping mutable segments of a
bit-slice, separated by bits that match a predicate function. Splitting advances
one segment at a time, starting at the end of the bit-slice.
The matched bit is **not** included in the yielded segment. The `n`th yielded
segment does not attempt any further splits, and extends to the front of the
bit-slice.
It is created by the [`BitSlice::rsplitn_mut`] method.
## Original
[`slice::SplitNMut`](core::slice::SplitNMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.rsplitn_mut(2, |idx, _bit| idx % 3 == 2);
split.next().unwrap().fill(false);
split.next().unwrap().fill(false);
assert!(split.next().is_none());
assert_eq!(bits, bits![0, 0, 0, 0, 0, 1, 0, 0]);
```
[`BitSlice::rsplitn_mut`]: crate::slice::BitSlice::rsplitn_mut
+35
View File
@@ -0,0 +1,35 @@
# Shared Bit-Slice Splitting
This iterator yields successive non-overlapping segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the beginning of the bit-slice.
The matched bit is **not** included in the yielded segment.
It is created by the [`BitSlice::split`] method.
## Original
[`slice::Split`](core::slice::Split)
## API Differences
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.split(|idx, _bit| idx % 3 == 2);
assert_eq!(split.next().unwrap(), bits![0; 2]);
assert_eq!(split.next().unwrap(), bits![1; 2]);
assert_eq!(split.next().unwrap(), bits![0, 1]);
assert!(split.next().is_none());
```
[`BitSlice::split`]: crate::slice::BitSlice::split
@@ -0,0 +1,29 @@
# Shared Bit-Slice Splitting
This iterator yields successive non-overlapping segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the beginning of the bit-slice.
The matched bit **is** included in the yielded segment.
It is created by the [`BitSlice::split_inclusive`] method.
## Original
[`slice::SplitInclusive`](core::slice::SplitInclusive)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.split_inclusive(|idx, _bit| idx % 3 == 2);
assert_eq!(split.next().unwrap(), bits![0; 3]);
assert_eq!(split.next().unwrap(), bits![1; 3]);
assert_eq!(split.next().unwrap(), bits![0, 1]);
assert!(split.next().is_none());
```
[`BitSlice::split_inclusive`]: crate::slice::BitSlice::split_inclusive
@@ -0,0 +1,33 @@
# Exclusive Bit-Slice Splitting
This iterator yields successive non-overlapping mutable segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the beginning of the bit-slice.
The matched bit **is** included in the yielded segment.
It is created by the [`BitSlice::split_inclusive_mut`] method.
## Original
[`slice::SplitInclusiveMut`](core::slice::SplitInclusiveMut)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut split = unsafe {
bits.split_inclusive_mut(|idx, _bit| idx % 3 == 2).remove_alias()
};
split.next().unwrap().fill(true);
split.next().unwrap().fill(false);
split.next().unwrap().copy_from_bitslice(bits![1, 0]);
assert!(split.next().is_none());
assert_eq!(bits, bits![1, 1, 1, 0, 0, 0, 1, 0]);
```
[`BitSlice::split_inclusive_mut`]: crate::slice::BitSlice::split_inclusive_mut
+41
View File
@@ -0,0 +1,41 @@
# Exclusive Bit-Slice Splitting
This iterator yields successive non-overlapping mutable segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the beginning of the bit-slice.
The matched bit is **not** included in the yielded segment.
It is created by the [`BitSlice::split_mut`] method.
## Original
[`slice::SplitMut`](core::slice::SplitMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut split = unsafe {
bits.split_mut(|idx, _bit| idx % 3 == 2).remove_alias()
};
split.next().unwrap().fill(true);
split.next().unwrap().fill(false);
split.next().unwrap().copy_from_bitslice(bits![1, 0]);
assert!(split.next().is_none());
assert_eq!(bits, bits![1, 1, 0, 0, 0, 1, 1, 0]);
```
[`BitSlice::split_mut`]: crate::slice::BitSlice::split_mut
+36
View File
@@ -0,0 +1,36 @@
# Shared Bit-Slice Splitting
This iterator yields `n` successive non-overlapping segments of a bit-slice,
separated by bits that match a predicate function. Splitting advances one
segment at a time, starting at the beginning of the bit-slice.
The matched bit is **not** included in the yielded segment. The `n`th yielded
segment does not attempt any further splits, and extends to the end of the
bit-slice.
It is created by the [`BitSlice::splitn`] method.
## Original
[`slice::SplitN`](core::slice::SplitN)
## API Differences
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.splitn(2, |idx, _bit| idx % 3 == 2);
assert_eq!(split.next().unwrap(), bits![0; 2]);
assert_eq!(split.next().unwrap(), bits![1, 1, 1, 0, 1]);
assert!(split.next().is_none());
```
[`BitSlice::splitn`]: crate::slice::BitSlice::splitn
+40
View File
@@ -0,0 +1,40 @@
# Exclusive Bit-Slice Splitting
This iterator yields `n` successive non-overlapping mutable segments of a
bit-slice, separated by bits that match a predicate function. Splitting advances
one segment at a time, starting at the beginning of the bit-slice.
The matched bit is **not** included in the yielded segment. The `n`th yielded
segment does not attempt any further splits, and extends to the end of the
bit-slice.
It is created by the [`BitSlice::splitn_mut`] method.
## Original
[`slice::SplitNMut`](core::slice::SplitNMut)
## API Differences
This iterator marks all yielded bit-slices as `::Alias`ed.
The predicate function receives both the index within the bit-slice, as well as
the bit value, in order to allow the predicate to have more than one bit of
information when splitting.
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
let mut split = bits.splitn_mut(2, |idx, _bit| idx % 3 == 2);
split.next().unwrap().fill(true);
split.next().unwrap().fill(false);
assert!(split.next().is_none());
assert_eq!(bits, bits![1, 1, 0, 0, 0, 0, 0, 0]);
```
[`BitSlice::splitn_mut`]: crate::slice::BitSlice::splitn_mut
+35
View File
@@ -0,0 +1,35 @@
# Bit-Slice Windowing
This iterator yields successive overlapping windows into a bit-slice. Windowing
advances one bit at a time, so for any given window width `N`, most bits will
appear in `N` windows. Windows do not “extend” past either edge of the
bit-slice: the first window has its front edge at the front of the bit-slice,
and the last window has its back edge at the back of the bit-slice.
It is created by the [`BitSlice::windows`] method.
## Original
[`slice::Windows`](core::slice::Windows)
## Examples
```rust
use bitvec::prelude::*;
let bits = bits![0, 0, 1, 1, 0];
let mut windows = bits.windows(2);
let expected = &[
bits![0, 0],
bits![0, 1],
bits![1, 1],
bits![1, 0],
];
assert_eq!(windows.len(), 4);
for (window, expected) in windows.zip(expected) {
assert_eq!(window, expected);
}
```
[`BitSlice::windows`]: crate::slice::BitSlice::windows