From cb7b2bf87e6b5ac38c626380dbbc2284f44ad367 Mon Sep 17 00:00:00 2001 From: jean-airoldie <25088801+jean-airoldie@users.noreply.github.com> Date: Wed, 6 Mar 2019 15:00:58 -0500 Subject: [PATCH] [Rust] Fixed codegen documentation for Tables (#5227) --- src/idl_gen_rust.cpp | 5 +++-- tests/monster_test_generated.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index fd6a06693..9d31265a4 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -1150,8 +1150,6 @@ class RustGenerator : public BaseGenerator { // Generate an accessor struct, builder struct, and create function for a // table. void GenTable(const StructDef &struct_def) { - GenComment(struct_def.doc_comment); - code_.SetValue("STRUCT_NAME", Name(struct_def)); code_.SetValue("OFFSET_TYPELABEL", Name(struct_def) + "Offset"); code_.SetValue("STRUCT_NAME_SNAKECASE", MakeSnakeCase(Name(struct_def))); @@ -1161,6 +1159,9 @@ class RustGenerator : public BaseGenerator { code_ += "pub enum {{OFFSET_TYPELABEL}} {}"; code_ += "#[derive(Copy, Clone, Debug, PartialEq)]"; code_ += ""; + + GenComment(struct_def.doc_comment); + code_ += "pub struct {{STRUCT_NAME}}<'a> {"; code_ += " pub _tab: flatbuffers::Table<'a>,"; code_ += "}"; diff --git a/tests/monster_test_generated.rs b/tests/monster_test_generated.rs index a538eaea8..8b18e968c 100644 --- a/tests/monster_test_generated.rs +++ b/tests/monster_test_generated.rs @@ -920,10 +920,10 @@ impl<'a: 'b, 'b> ReferrableBuilder<'a, 'b> { } } -/// an example documentation comment: monster object pub enum MonsterOffset {} #[derive(Copy, Clone, Debug, PartialEq)] +/// an example documentation comment: monster object pub struct Monster<'a> { pub _tab: flatbuffers::Table<'a>, }