Skip to content

[Rust]: Object API codegen for arrays missing Default trait implementation #8943

@pveierland

Description

@pveierland

When building the following schema using flatc --rust --gen-object-api hash_digest.fbs:

struct HashDigest {
    size: uint8 (id: 0);
    data: [uint8:64] (id: 1);
}

The generated object API rust code is:

#[derive(Debug, Clone, PartialEq, Default)]
pub struct HashDigestT {
  pub size: u8,
  pub data: [u8; 64],
}

This fails to build as there is no implementation of the Default trait for the array:

error[E0277]: the trait bound `[u8; 64]: Default` is not satisfied

This appears to be a bug and the expectation is that the generated code will build given this schema.

Tested with flatc version 25.12.19.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr-requestedA Pull Request is requested to move the issue forward.rust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions