| 1 |
# Bit-Vector Extension |
| 2 |
|
| 3 |
This extends a bit-vector from anything that produces individual bits. |
| 4 |
|
| 5 |
## Original |
| 6 |
|
| 7 |
[`impl<T> Extend<T> for Vec<T>`][orig] |
| 8 |
|
| 9 |
## Notes |
| 10 |
|
| 11 |
This `.extend()` call is the second-slowest possible way to append bits into a |
| 12 |
bit-vector, faster only than calling `iter.for_each(|bit| bv.push(bit))`. |
| 13 |
**DO NOT** use this if you have any other choice. |
| 14 |
|
| 15 |
If you are extending a bit-vector from the contents of a bit-slice, then you |
| 16 |
should use [`.extend_from_bitslice()`] instead. That method is specialized to |
| 17 |
perform upfront allocation and, where possible, use a batch copy rather than |
| 18 |
copying each bit individually from the source into the bit-vector. |
| 19 |
|
| 20 |
[orig]: https://doc.rust-lang.org/alloc/vec/struct.Vec.html#impl-Extend%3CT%3E |
| 21 |
[`.extend_from_bitslice()`]: crate::vec::BitVec::extend_from_bitslice |