Skip to content

[Rust] Codegen should support BuilderArgs structs with required fields not being Option<T> #8598

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

Open
v3xro opened this issue May 14, 2025 · 0 comments · May be fixed by #8601
Open

[Rust] Codegen should support BuilderArgs structs with required fields not being Option<T> #8598

v3xro opened this issue May 14, 2025 · 0 comments · May be fixed by #8601

Comments

@v3xro
Copy link

v3xro commented May 14, 2025

The current Rust codegen (specifically here) generates an args struct with Option<T> fields even when those fields are marked as (required) in the .fbs definition.

Example:

table Message {
  name: string (required);
}
pub struct MessageArgs {
  pub name: Option<flatbuffers::WIPOffset<&'a str>>,
}

// ... 

let msg = Message::create(&mut builder, &MessageArgs { ..Default::default() }); // panic, oh no

It would be nice for compile-time safety if creating these flatbuffer messages it was a compile-time failure if things were not specified (and I would be prepared to live with a flag that disables the builder style completely in that case).

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

Successfully merging a pull request may close this issue.

1 participant