File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,13 @@ mod sealed { // You should just use the type aliases instead.
38
38
/// The bit used to signify that the feature is optional.
39
39
const ODD_BIT : usize = $odd_bit;
40
40
41
+ /// Assertion that [`ODD_BIT`] is actually odd.
42
+ const ASSERT_BIT_PARITY : usize ;
43
+
44
+ /// Assertion that [`ODD_BIT`] is at most `EVEN_BIT + 1`. Allows for special cases
45
+ /// where a feature only has one bit and thus `EVEN_BIT == ODD_BIT`.
46
+ const ASSERT_BIT_PROXIMITY : usize ;
47
+
41
48
/// The byte where the feature is set.
42
49
const BYTE_OFFSET : usize = Self :: EVEN_BIT / 8 ;
43
50
@@ -78,7 +85,14 @@ mod sealed { // You should just use the type aliases instead.
78
85
}
79
86
80
87
$(
81
- impl $feature for $context { }
88
+ impl $feature for $context {
89
+ // ODD_BIT % 2 == 1
90
+ const ASSERT_BIT_PARITY : usize = ( <Self as $feature>:: ODD_BIT % 2 ) - 1 ;
91
+
92
+ // ODD_BIT == EVEN_BIT + 1 || ODD_BIT == EVEN_BIT
93
+ const ASSERT_BIT_PROXIMITY : usize =
94
+ 1 - ( <Self as $feature>:: ODD_BIT - <Self as $feature>:: EVEN_BIT ) ;
95
+ }
82
96
) *
83
97
}
84
98
}
You can’t perform that action at this time.
0 commit comments