8000 [Rust] Codegen should support BuilderArgs structs with required fields not being `Option<T>` · Issue #8598 · google/flatbuffers · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Rust] Codegen should support BuilderArgs structs with required fields not being Option<T> #8598
Open
@v3xro

Description

@v3xro

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0