layered_bitset/
indirect.rs

1use super::{BitSet, BitSetMut};
2
3#[cfg(feature = "alloc")]
4use alloc::boxed::Box;
5
6impl<T> BitSet for &'_ T
7where
8    T: BitSet,
9{
10    const UPPER_BOUND: u32 = T::UPPER_BOUND;
11
12    fn get(&self, index: u32) -> bool {
13        T::get(*self, index)
14    }
15
16    fn find_set(&self, lower_bound: u32) -> Option<u32> {
17        T::find_set(*self, lower_bound)
18    }
19}
20
21impl<T> BitSet for &'_ mut T
22where
23    T: BitSet,
24{
25    const UPPER_BOUND: u32 = T::UPPER_BOUND;
26
27    fn get(&self, index: u32) -> bool {
28        T::get(*self, index)
29    }
30
31    fn find_set(&self, lower_bound: u32) -> Option<u32> {
32        T::find_set(*self, lower_bound)
33    }
34}
35
36impl<T> BitSetMut for &'_ mut T
37where
38    T: BitSetMut,
39{
40    fn set(&mut self, index: u32, bit: bool) {
41        T::set(*self, index, bit)
42    }
43}
44
45#[cfg(feature = "alloc")]
46impl<T> BitSet for Box<T>
47where
48    T: BitSet,
49{
50    const UPPER_BOUND: u32 = T::UPPER_BOUND;
51
52    fn get(&self, index: u32) -> bool {
53        T::get(&**self, index)
54    }
55
56    fn find_set(&self, lower_bound: u32) -> Option<u32> {
57        T::find_set(&**self, lower_bound)
58    }
59}
60
61#[cfg(feature = "alloc")]
62impl<T> BitSetMut for Box<T>
63where
64    T: BitSetMut,
65{
66    fn set(&mut self, index: u32, bit: bool) {
67        T::set(&mut **self, index, bit)
68    }
69}