File: ops.md

package info (click to toggle)
rust-bitvec 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,780 kB
  • sloc: makefile: 2
file content (16 lines) | stat: -rw-r--r-- 780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Bit-Slice Operator Implementations

The standard-library slices only implement the indexing operator `[]`.
`BitSlice` additionally implements the Boolean operators `&`, `|`, `^`, and `!`.

The dyadic Boolean arithmetic operators all take any `bitvec` container as their
second argument, and apply the operation in-place to the left-hand bit-slice. If
the second argument exhausts before `self` does, then it is implicitly
zero-extended. This means that `&=` zeros excess bits in `self`, while `|=` and
`^=` do not modify them.

The monadic operator `!` inverts the entire bit-slice at once. Its API requires
*taking* a `&mut BitSlice` reference and returning it, so you will need to
structure your code accordingly.

[`BitSlice::domain_mut`]: crate::slice::BitSlice::domain_mut