mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 06:54:26 +00:00
Fixed rust nested flatbuffers for tables other than self (#6062)
* Fixed rust nested flatbuffers for tables other than self * replaced lifetimes * Use WrapInNameSpace and also update samples Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -15,13 +15,13 @@ namespace MyGame.Example;
|
||||
attribute "priority";
|
||||
|
||||
/// Composite components of Monster color.
|
||||
enum Color:ubyte (bit_flags) {
|
||||
enum Color:ubyte (bit_flags) {
|
||||
Red = 0, // color Red = (1u << 0)
|
||||
/// \brief color Green
|
||||
/// Green is bit_flag with value (1u << 1)
|
||||
Green,
|
||||
Green,
|
||||
/// \brief color Blue (1u << 3)
|
||||
Blue = 3,
|
||||
Blue = 3,
|
||||
}
|
||||
|
||||
enum Race:byte {
|
||||
|
||||
@@ -1211,14 +1211,11 @@ impl<'a> Monster<'a> {
|
||||
pub fn testnestedflatbuffer(&self) -> Option<&'a [u8]> {
|
||||
self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None).map(|v| v.safe_slice())
|
||||
}
|
||||
pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
|
||||
match self.testnestedflatbuffer() {
|
||||
None => { None }
|
||||
Some(data) => {
|
||||
use self::flatbuffers::Follow;
|
||||
Some(<flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data, 0))
|
||||
},
|
||||
}
|
||||
pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
|
||||
self.testnestedflatbuffer().map(|data| {
|
||||
use flatbuffers::Follow;
|
||||
<flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data, 0)
|
||||
})
|
||||
}
|
||||
#[inline]
|
||||
pub fn testempty(&self) -> Option<Stat<'a>> {
|
||||
|
||||
Reference in New Issue
Block a user