| 1 |
# Writing Into a Bit-Slice |
| 2 |
|
| 3 |
The implementation stores bytes into the referenced bit-slice until either the |
| 4 |
source buffer is exhausted or the destination has no more slots to fill. When |
| 5 |
`.write()` returns, the provided bit-slice handle will have been updated to no |
| 6 |
longer include the leading segment filled with bytes from `buf`. |
| 7 |
|
| 8 |
Note that the return value of `.write()` is always the number of *bytes* of |
| 9 |
`buf` consumed! |
| 10 |
|
| 11 |
The implementation uses [`BitField::store_be`] to fill bytes. Note that unlike |
| 12 |
the standard library, it is implemented on bit-slices of *any* underlying |
| 13 |
element type. However, using a `BitSlice<_, u8>` is still likely to be fastest. |
| 14 |
|
| 15 |
## Original |
| 16 |
|
| 17 |
[`impl Write for [u8]`][orig] |
| 18 |
|
| 19 |
[orig]: https://doc.rust-lang.org/std/primitive.slice.html#impl-Write |
| 20 |
[`BitField::store_be`]: crate::field::BitField::store_be |