File: Write_BitVec.md

package info (click to toggle)
rust-coreutils 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 505,620 kB
  • sloc: ansic: 103,594; asm: 28,570; sh: 8,910; python: 5,581; makefile: 472; cpp: 97; javascript: 72
file content (18 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Writing Into a Bit-Vector

The implementation appends bytes to the referenced bit-vector until the source
buffer is exhausted.

Note that the return value of `.write()` is always the number of *bytes* of
`buf` consumed!

The implementation uses [`BitField::store_be`] to fill bytes. Note that unlike
the standard library, it is implemented on bit-vectors of *any* underlying
element type. However, using a `BitVec<_, u8>` is still likely to be fastest.

## Original

[`impl Write for Vec<u8>`][orig]

[orig]: https://doc.rust-lang.org/std/vec/struct.Vec.html#impl-Write
[`BitField::store_be`]: crate::field::BitField::store_be