Skip to content
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

Feature Request: Ability to specify default value for field #105

Open
ohunter opened this issue Apr 19, 2024 · 0 comments
Open

Feature Request: Ability to specify default value for field #105

ohunter opened this issue Apr 19, 2024 · 0 comments

Comments

@ohunter
Copy link

ohunter commented Apr 19, 2024

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()....;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant