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);
Implementations§
Trait Implementations§
impl<'map, const BYTES: usize> Copy for BitRef<'map, BYTES>
Auto Trait Implementations§
impl<'map, const BYTES: usize> Freeze for BitRef<'map, BYTES>
impl<'map, const BYTES: usize> RefUnwindSafe for BitRef<'map, BYTES>
impl<'map, const BYTES: usize> Send for BitRef<'map, BYTES>
impl<'map, const BYTES: usize> Sync for BitRef<'map, BYTES>
impl<'map, const BYTES: usize> Unpin for BitRef<'map, BYTES>
impl<'map, const BYTES: usize> UnwindSafe for BitRef<'map, BYTES>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more