feat: container tests
This commit is contained in:
parent
6dc79f7e29
commit
0b1486aeee
3 changed files with 339 additions and 316 deletions
16
src/lib.rs
16
src/lib.rs
|
@ -3,6 +3,8 @@
|
|||
This crate aims to make working with binary/bit flags easier. It also provides a macro to add similar functionality to zig's packed structs with boolean fields.
|
||||
*/
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
pub use binf_macros::*;
|
||||
|
||||
/// A trait for types that can be used as bit flags.
|
||||
|
@ -218,3 +220,17 @@ impl<T: BitFlag> BitFlags<T> {
|
|||
self.0.set_flags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: BitFlag> Deref for BitFlags<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: BitFlag> DerefMut for BitFlags<T> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
|
7
tests/container.rs
Normal file
7
tests/container.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use binf::BitFlags;
|
||||
|
||||
#[test]
|
||||
fn standalone() {
|
||||
let flags = BitFlags::<u8>::new(0b10101010);
|
||||
assert_eq!(*flags, 0b10101010);
|
||||
}
|
Loading…
Reference in a new issue