modular-bitfield
modular-bitfield copied to clipboard
Feature Request: Ability to specify default value for field
I have a struct where one flag has to be 1 no matter what. With the current implementation I have to do something like this no matter what which doesn't really feel ergonomic:
#[bitfield]
struct Foo {
pub foo: bool,
pub field_has_to_be_there: bool,
pub bar: bool,
#[skip] __: B5,
}
let foo = Foo::new().with_field_has_to_be_there(true)....;
I'd like for something like this to be possible:
#[bitfield]
struct Foo {
pub foo: bool,
#[default(true), skip] __: bool,
pub bar: bool,
#[skip] __: B5,
}
let foo = Foo::new()....;