Open
Description
Issue
Invalid generation of rust code with switch --gen-object-api
and struct containing array
of size 33
and more.
Reason
Generated object api struct implement Default
trait by derive
macro, but array
implement Default
trait only for size up to 32
(source).
Example of invalid fbs
Fbs file example.fbs
namespace example;
struct FooStruct {
array_values: [double:81];
}
table FooTable {
foo_struct: FooStruct;
}
root_type FooTable;
Command
flatc.exe --rust --gen-object-api example.fbs
Invalid code section
#[derive(Debug, Clone, PartialEq, Default)]
pub struct FooStructT {
pub array_values: [f64; 81],
}
Tool versions
flatc - 24.3.25
rustc - 1.82.0
Potential solution
For struct
with array
implement custom Default
trait.
Example of solution from code above
#[derive(Debug, Clone, PartialEq)]
pub struct FooStructT {
pub array_values: [f64; 81],
}
impl std::default::Default for FooStructT {
fn default() -> Self {
Self {
array_values: [Default::default(); 81],
}
}
}
Metadata
Metadata
Assignees
Labels
No labels