1 | /// A simple macro for defining bitfield accessors/mutators. |
2 | #[cfg (feature = "alloc" )] |
3 | macro_rules! define_bool { |
4 | ($bit:expr, $is_fn_name:ident, $set_fn_name:ident) => { |
5 | fn $is_fn_name(&self) -> bool { |
6 | self.bools & (0b1 << $bit) > 0 |
7 | } |
8 | |
9 | fn $set_fn_name(&mut self, yes: bool) { |
10 | if yes { |
11 | self.bools |= 1 << $bit; |
12 | } else { |
13 | self.bools &= !(1 << $bit); |
14 | } |
15 | } |
16 | }; |
17 | } |
18 | |
19 | macro_rules! log { |
20 | ($($tt:tt)*) => { |
21 | #[cfg(feature = "logging" )] |
22 | { |
23 | $($tt)* |
24 | } |
25 | } |
26 | } |
27 | |
28 | macro_rules! trace { |
29 | ($($tt:tt)*) => { log!(log::trace!($($tt)*)) } |
30 | } |
31 | |