mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 23:28:06 +00:00
Refactor idl_gen_rust and Rust generated code to use consistent whitespace (#6809)
* Remove dead code in idl_gen_rust * Use 2space indentation in mod.rs * use In/DecrementIdentValue in idl_gen_rust Fix some whitespace too in generated code. * make default fn 2space ident * More 2space formatting * git clang format * make vs2015 happy Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
mod test_enum_generated;
|
||||
pub use self::test_enum_generated::*;
|
||||
mod nested_struct_generated;
|
||||
pub use self::nested_struct_generated::*;
|
||||
mod array_struct_generated;
|
||||
pub use self::array_struct_generated::*;
|
||||
mod array_table_generated;
|
||||
pub use self::array_table_generated::*;
|
||||
} // example
|
||||
mod test_enum_generated;
|
||||
pub use self::test_enum_generated::*;
|
||||
mod nested_struct_generated;
|
||||
pub use self::nested_struct_generated::*;
|
||||
mod array_struct_generated;
|
||||
pub use self::array_struct_generated::*;
|
||||
mod array_table_generated;
|
||||
pub use self::array_table_generated::*;
|
||||
} // example
|
||||
} // my_game
|
||||
|
||||
@@ -93,9 +93,9 @@ impl<'a> ArrayStruct {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayStruct"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayStruct"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<f32>::uninit();
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct ArrayTable<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for ArrayTable<'a> {
|
||||
type Inner = ArrayTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = ArrayTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ArrayTable<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayTable"
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ArrayTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ArrayTableArgs<'args>) -> flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayTable"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayTableT {
|
||||
let a = self.a().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
ArrayTableT {
|
||||
a,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ArrayTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ArrayTableArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayTableT {
|
||||
let a = self.a().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
ArrayTableT {
|
||||
a,
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<&'a ArrayStruct> {
|
||||
@@ -69,12 +71,12 @@ pub struct ArrayTableArgs<'a> {
|
||||
pub a: Option<&'a ArrayStruct>,
|
||||
}
|
||||
impl<'a> Default for ArrayTableArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ArrayTableArgs {
|
||||
a: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ArrayTableArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct ArrayTableBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -87,9 +87,9 @@ impl<'a> NestedStruct {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.NestedStruct"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.NestedStruct"
|
||||
}
|
||||
|
||||
pub fn a(&'a self) -> flatbuffers::Array<'a, i32, 2> {
|
||||
flatbuffers::Array::follow(&self.0, 0)
|
||||
|
||||
Reference in New Issue
Block a user