1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use core::ops::Bound;
use core::ops::Range;
use core::ops::RangeBounds;
use core::ops::RangeFrom;
use core::ops::RangeFull;
use core::ops::RangeInclusive;
use core::ops::RangeTo;
use core::ops::RangeToInclusive;
pub trait BitIndex {
fn low(&self) -> Bound<&u32>;
fn upper(&self) -> Bound<&u32>;
}
impl BitIndex for RangeInclusive<u32> {
#[inline]
fn upper(&self) -> Bound<&u32> {
self.end_bound()
}
#[inline]
fn low(&self) -> Bound<&u32> {
self.start_bound()
}
}
impl BitIndex for RangeFull {
#[inline]
fn low(&self) -> Bound<&u32> {
Bound::Included(&0)
}
#[inline]
fn upper(&self) -> Bound<&u32> {
Bound::Unbounded
}
}
impl BitIndex for RangeFrom<u32> {
#[inline]
fn low(&self) -> Bound<&u32> {
self.start_bound()
}
#[inline]
fn upper(&self) -> Bound<&u32> {
Bound::Unbounded
}
}
impl BitIndex for RangeTo<u32> {
#[inline]
fn low(&self) -> Bound<&u32> {
Bound::Included(&0)
}
#[inline]
fn upper(&self) -> Bound<&u32> {
self.end_bound()
}
}
impl BitIndex for Range<u32> {
#[inline]
fn upper(&self) -> Bound<&u32> {
self.end_bound()
}
#[inline]
fn low(&self) -> Bound<&u32> {
self.start_bound()
}
}
impl BitIndex for u32 {
#[inline]
fn upper(&self) -> Bound<&u32> {
Bound::Included(self)
}
#[inline]
fn low(&self) -> Bound<&u32> {
Bound::Included(self)
}
}
impl BitIndex for RangeToInclusive<u32> {
#[inline]
fn low(&self) -> Bound<&u32> {
Bound::Included(&0)
}
#[inline]
fn upper(&self) -> Bound<&u32> {
self.end_bound()
}
}