Skip to content

Commit cb7b2bf

Browse files
jean-airoldierw
authored andcommitted
[Rust] Fixed codegen documentation for Tables (google#5227)
1 parent bfa4303 commit cb7b2bf

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/idl_gen_rust.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,6 @@ class RustGenerator : public BaseGenerator {
11501150
// Generate an accessor struct, builder struct, and create function for a
11511151
// table.
11521152
void GenTable(const StructDef &struct_def) {
1153-
GenComment(struct_def.doc_comment);
1154-
11551153
code_.SetValue("STRUCT_NAME", Name(struct_def));
11561154
code_.SetValue("OFFSET_TYPELABEL", Name(struct_def) + "Offset");
11571155
code_.SetValue("STRUCT_NAME_SNAKECASE", MakeSnakeCase(Name(struct_def)));
@@ -1161,6 +1159,9 @@ class RustGenerator : public BaseGenerator {
11611159
code_ += "pub enum {{OFFSET_TYPELABEL}} {}";
11621160
code_ += "#[derive(Copy, Clone, Debug, PartialEq)]";
11631161
code_ += "";
1162+
1163+
GenComment(struct_def.doc_comment);
1164+
11641165
code_ += "pub struct {{STRUCT_NAME}}<'a> {";
11651166
code_ += " pub _tab: flatbuffers::Table<'a>,";
11661167
code_ += "}";

tests/monster_test_generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,10 @@ impl<'a: 'b, 'b> ReferrableBuilder<'a, 'b> {
920920
}
921921
}
922922

923-
/// an example documentation comment: monster object
924923
pub enum MonsterOffset {}
925924
#[derive(Copy, Clone, Debug, PartialEq)]
926925

926+
/// an example documentation comment: monster object
927927
pub struct Monster<'a> {
928928
pub _tab: flatbuffers::Table<'a>,
929929
}

0 commit comments

Comments
 (0)