-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting field alters other field #11
Comments
Hi! |
I slightly modified the test case to: use modular_bitfield::prelude::*;
#[derive(BitfieldSpecifier, Debug, PartialEq, Copy, Clone)]
pub enum Mode {
A = 0b00,
B = 0b01,
C = 0b10,
D = 0b11,
}
#[bitfield]
#[derive(Debug)]
pub struct StatFlag {
x: bool,
y: bool,
z: B4,
#[bits = 2]
mode: Mode,
}
fn main() {
let mut flag = StatFlag::new();
assert_eq!(flag.get_x(), false);
assert_eq!(flag.get_y(), false);
assert_eq!(flag.get_z(), 0);
assert_eq!(flag.get_mode(), Mode::A);
let new_mode = Mode::B;
flag.set_mode(new_mode);
assert_eq!(flag.get_mode(), new_mode);
flag.set_x(true);
assert_eq!(flag.get_x(), true);
assert_eq!(flag.get_mode(), new_mode);
flag.set_y(true);
assert_eq!(flag.get_y(), true);
assert_eq!(flag.get_mode(), new_mode);
flag.set_z(0b11);
assert_eq!(flag.get_z(), 0b11);
assert_eq!(flag.get_mode(), new_mode);
} The problem seems to be that the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modifying almost any field changes the
mode
field back to the zero valued form ofStatMode
,HBlank
.src/main.rs
Cargo.toml
The text was updated successfully, but these errors were encountered: