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
use std::fmt;
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Bitfield24_8(u32);
impl Bitfield24_8 {
#[inline]
pub const fn new(low: u32, high: u8) -> Self {
Self((low & 0x00FF_FFFF) | ((high as u32) << 24))
}
#[inline]
pub const fn low(self) -> u32 {
self.0 & 0x00FF_FFFF
}
#[inline]
pub const fn high(self) -> u8 {
(self.0 >> 24) as u8
}
}
impl fmt::Debug for Bitfield24_8 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Bitfield24_8(low={}, high={})", self.low(), self.high())
}
}