pub struct BitRef<'map, const BYTES: usize> { /* private fields */ }Expand description
A wrapper of the immutable reference to a bit in the bitmap.
The wrapper owns a ref to the map.
Examples
To get a new wrapper:
use cbitmap::bitmap::*;
let mut map = newmap!(;8);
let rmap = ↦
let bit1 = map.at(1);
let bit2 = BitRef::<1>::new(rmap, 2);Use deref to get the bool value:
use cbitmap::bitmap::*;
let rmap = &newmap!(0b_0010; 8);
let bit = rmap.at(1);
assert_eq!(*bit, true);Copy is implemented:
use cbitmap::bitmap::*;
let rmap = &newmap!(1; 8);
let bit1 = rmap.at(0);
let bit2 = bit1;
// bit1 is copied but not moved to bit2
assert_eq!(*bit1, true);Convert to bool use Into<bool>:
use cbitmap::bitmap::*;
let map = newmap!(;8);
let bit = map.at(1);
assert_eq!(Into::<bool>::into(bit), false);
// Panic! Since bitmut is already moved:
// assert_eq!(Into::<bool>::into(bit), false);