Squashed 'third_party/flatbuffers/' changes from bc44fad35..8aa8b9139
8aa8b9139 Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588)
001adf782 Add support for parsing proto map fields (#7613)
dbc58ab77 Fix help output for --gen-includes (#7611)
2facfeec7 Fix missing spaces in flatc help text (#7612)
4de2814c7 Fix: arduino platform build (#7625)
37b1acdaf Fix current official name of macOS (#7627)
a22434e2a Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624)
214cc9468 Bump Rust version to 22.10.26 before publication (#7622)
a4ff275d9 Added option to not requires an EoF token when parsing JSON (#7620)
15f32c690 python: object generation prefix and suffix (#7565)
051afd882 Add CreateSharedString to python builder (#7608)
728c033ad Add check for presence of realpath to CMakeLists.txt to support more platforms (#7603)
4c514483d Update DartTest.sh golden files (#7606)
c2d9c2080 [TS] Add support for fixed length arrays on Typescript (#5864) (#7021) (#7581)
e34ae4c6b `build.yml`: Fix missing 'v' in version
e54536127 `build.yml` Update to Kotlin Wrapper 1.0.5
49d9f941c `release.yml` Use env var for passphrase
cefc21c1f `release.yml` Add GPG key for Maven
3e64fa724 `release.yml`: Add Maven Steps
b15f3c57e `release_yml` Use new dotnet version
ff802c680 `release.yml` Use NuGet Key directly
b401957d5 `release.yml` Changed Push to follow examples
8c8151f8f `release.yml` Fix nuget push command
ebb7c203d `release.yml` Add Nuget support
203241ed3 FlatBuffers Version 22.10.26 (#7607)
ac485609c `setup.py`: Define version directly
de5b85aa6 `release.yml`: Switch to `python` directory
de3df2d88 `release.yml`: Add publishing to PyPi
043a24f2e [Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576)
5a48b0d7d release.yml: Typo
ce307556f release.yml: Remove `npm ci`
cb616e27c Create release.yml (#7605)
a54ca1e75 FlatBuffers Version 22.10.25 (#7604)
5b3fadcc1 [vector] Allow to iterate with mutables (#7586)
872a49746 [Nim] Bfbs Nim Generator (#7534)
e30170296 Make type conversions explicit. (#7595)
f7b734438 Fix LongEnum definitions (#7596)
5792623df Rust fix compilation for no_std targets #2 (#7553)
0edb27528 Update Rust version (#7574)
acc6a20d3 tests/test.cpp contains a couple of tests that are only executed (#7571)
04cd037ba Fix #7580 by documenting union schema evolution rules (#7585)
e1c5db988 Turn on clippy for Rust and fix lints for non-generated code (#7575)
b80142b90 Update documentation to mention enum value attributes (#7570)
54418f371 Add support for metadata attributes for enum values (#7567) (#7568)
c92e78a9f FlatBuffers Version 22.9.29 (#7557)
d243b904c [TS] Make strict compliant and improve typings (#7549)
374f8fb5f Rust soundness fixes (#7518)
dadbff571 Moves swift package to root of repository so it can be used directly … (#7548)
76ddae006 FlatBuffers Version 22.9.24 (#7547)
cfe157ec5 Emit internal enums when swift_implementation_only (#7545)
413115858 [Python] Python fixed size array (#7529)
88046190e Upgrade grpc to 1.49.0 and make sure it builds (#7538)
72aa85a75 [C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520)
bfceebb7f Fix conform (#7532)
git-subtree-dir: third_party/flatbuffers
git-subtree-split: 8aa8b9139eb330f27816a5b8b5bbef402fbe3632
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
Change-Id: I943faba499baf58e9f561b1e4734922188ba8626
diff --git a/samples/monster.bfbs b/samples/monster.bfbs
index 99a93f5..5b47002 100644
--- a/samples/monster.bfbs
+++ b/samples/monster.bfbs
Binary files differ
diff --git a/samples/monster_generated.h b/samples/monster_generated.h
index 8c24d17..31db6a1 100644
--- a/samples/monster_generated.h
+++ b/samples/monster_generated.h
@@ -8,9 +8,9 @@
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
-static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
- FLATBUFFERS_VERSION_MINOR == 0 &&
- FLATBUFFERS_VERSION_REVISION == 8,
+static_assert(FLATBUFFERS_VERSION_MAJOR == 22 &&
+ FLATBUFFERS_VERSION_MINOR == 10 &&
+ FLATBUFFERS_VERSION_REVISION == 26,
"Non-compatible flatbuffers version included");
namespace MyGame {
diff --git a/samples/monster_generated.swift b/samples/monster_generated.swift
index 173bacb..72e0e71 100644
--- a/samples/monster_generated.swift
+++ b/samples/monster_generated.swift
@@ -31,7 +31,7 @@
public struct MyGame_Sample_Vec3: NativeStruct {
- static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ static func validateVersion() { FlatBuffersVersion_22_10_26() }
private var _x: Float32
private var _y: Float32
@@ -56,7 +56,7 @@
public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ static func validateVersion() { FlatBuffersVersion_22_10_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -72,7 +72,7 @@
public struct MyGame_Sample_Monster: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ static func validateVersion() { FlatBuffersVersion_22_10_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -162,7 +162,7 @@
public struct MyGame_Sample_Weapon: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ static func validateVersion() { FlatBuffersVersion_22_10_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
diff --git a/samples/rust_generated/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs
index 7a7d1d5..19e8445 100644
--- a/samples/rust_generated/my_game/sample/color_generated.rs
+++ b/samples/rust_generated/my_game/sample/color_generated.rs
@@ -59,10 +59,8 @@
impl<'a> flatbuffers::Follow<'a> for Color {
type Inner = Self;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe {
- flatbuffers::read_scalar_at::<i8>(buf, loc)
- };
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
Self(b)
}
}
@@ -70,21 +68,21 @@
impl flatbuffers::Push for Color {
type Output = Color;
#[inline]
- fn push(&self, dst: &mut [u8], _rest: &[u8]) {
- unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); }
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ flatbuffers::emplace_scalar::<i8>(dst, self.0);
}
}
impl flatbuffers::EndianScalar for Color {
+ type Scalar = i8;
#[inline]
- fn to_little_endian(self) -> Self {
- let b = i8::to_le(self.0);
- Self(b)
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
- fn from_little_endian(self) -> Self {
- let b = i8::from_le(self.0);
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
Self(b)
}
}
diff --git a/samples/rust_generated/my_game/sample/equipment_generated.rs b/samples/rust_generated/my_game/sample/equipment_generated.rs
index 9898c8d..9f9cd35 100644
--- a/samples/rust_generated/my_game/sample/equipment_generated.rs
+++ b/samples/rust_generated/my_game/sample/equipment_generated.rs
@@ -55,10 +55,8 @@
impl<'a> flatbuffers::Follow<'a> for Equipment {
type Inner = Self;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe {
- flatbuffers::read_scalar_at::<u8>(buf, loc)
- };
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
Self(b)
}
}
@@ -66,21 +64,21 @@
impl flatbuffers::Push for Equipment {
type Output = Equipment;
#[inline]
- fn push(&self, dst: &mut [u8], _rest: &[u8]) {
- unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
}
}
impl flatbuffers::EndianScalar for Equipment {
+ type Scalar = u8;
#[inline]
- fn to_little_endian(self) -> Self {
- let b = u8::to_le(self.0);
- Self(b)
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
- fn from_little_endian(self) -> Self {
- let b = u8::from_le(self.0);
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
Self(b)
}
}
diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs
index 273212f..68ba6d5 100644
--- a/samples/rust_generated/my_game/sample/monster_generated.rs
+++ b/samples/rust_generated/my_game/sample/monster_generated.rs
@@ -19,8 +19,8 @@
impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: flatbuffers::Table { buf, loc } }
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table::new(buf, loc) }
}
}
@@ -41,7 +41,7 @@
}
#[inline]
- pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
+ pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Monster { _tab: table }
}
#[allow(unused_mut)]
@@ -73,7 +73,7 @@
x.to_string()
});
let inventory = self.inventory().map(|x| {
- x.to_vec()
+ x.into_iter().collect()
});
let color = self.color();
let weapons = self.weapons().map(|x| {
@@ -106,49 +106,84 @@
#[inline]
pub fn pos(&self) -> Option<&'a Vec3> {
- self._tab.get::<Vec3>(Monster::VT_POS, None)
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
#[inline]
pub fn mana(&self) -> i16 {
- self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
}
#[inline]
pub fn hp(&self) -> i16 {
- self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
}
#[inline]
pub fn name(&self) -> Option<&'a str> {
- self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
}
#[inline]
- pub fn inventory(&self) -> Option<&'a [u8]> {
- self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None).map(|v| v.safe_slice())
+ pub fn inventory(&self) -> Option<flatbuffers::Vector<'a, u8>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
}
#[inline]
pub fn color(&self) -> Color {
- self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
}
#[inline]
pub fn weapons(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
- self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
}
#[inline]
pub fn equipped_type(&self) -> Equipment {
- self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
}
#[inline]
pub fn equipped(&self) -> Option<flatbuffers::Table<'a>> {
- self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
}
#[inline]
- pub fn path(&self) -> Option<&'a [Vec3]> {
- self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None).map(|v| v.safe_slice())
+ pub fn path(&self) -> Option<flatbuffers::Vector<'a, Vec3>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
}
#[inline]
#[allow(non_snake_case)]
pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
if self.equipped_type() == Equipment::Weapon {
- self.equipped().map(Weapon::init_from_table)
+ self.equipped().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Weapon::init_from_table(t) }
+ })
} else {
None
}
@@ -366,18 +401,6 @@
}
}
#[inline]
-#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
-pub fn get_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
- unsafe { flatbuffers::root_unchecked::<Monster<'a>>(buf) }
-}
-
-#[inline]
-#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
-pub fn get_size_prefixed_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
- unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster<'a>>(buf) }
-}
-
-#[inline]
/// Verifies that a buffer of bytes contains a `Monster`
/// and returns it.
/// Note that verification is still experimental and may not
diff --git a/samples/rust_generated/my_game/sample/vec_3_generated.rs b/samples/rust_generated/my_game/sample/vec_3_generated.rs
index 894186b..185677f 100644
--- a/samples/rust_generated/my_game/sample/vec_3_generated.rs
+++ b/samples/rust_generated/my_game/sample/vec_3_generated.rs
@@ -29,39 +29,25 @@
}
impl flatbuffers::SimpleToVerifyInSlice for Vec3 {}
-impl flatbuffers::SafeSliceAccess for Vec3 {}
impl<'a> flatbuffers::Follow<'a> for Vec3 {
type Inner = &'a Vec3;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
<&'a Vec3>::follow(buf, loc)
}
}
impl<'a> flatbuffers::Follow<'a> for &'a Vec3 {
type Inner = &'a Vec3;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
}
}
impl<'b> flatbuffers::Push for Vec3 {
type Output = Vec3;
#[inline]
- fn push(&self, dst: &mut [u8], _rest: &[u8]) {
- let src = unsafe {
- ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
- };
- dst.copy_from_slice(src);
- }
-}
-impl<'b> flatbuffers::Push for &'b Vec3 {
- type Output = Vec3;
-
- #[inline]
- fn push(&self, dst: &mut [u8], _rest: &[u8]) {
- let src = unsafe {
- ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
- };
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size());
dst.copy_from_slice(src);
}
}
@@ -95,70 +81,88 @@
}
pub fn x(&self) -> f32 {
- let mut mem = core::mem::MaybeUninit::<f32>::uninit();
- unsafe {
+ let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ EndianScalar::from_little_endian(unsafe {
core::ptr::copy_nonoverlapping(
self.0[0..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
mem.assume_init()
- }.from_little_endian()
+ })
}
pub fn set_x(&mut self, x: f32) {
let x_le = x.to_little_endian();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
unsafe {
core::ptr::copy_nonoverlapping(
- &x_le as *const f32 as *const u8,
+ &x_le as *const _ as *const u8,
self.0[0..].as_mut_ptr(),
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
}
}
pub fn y(&self) -> f32 {
- let mut mem = core::mem::MaybeUninit::<f32>::uninit();
- unsafe {
+ let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ EndianScalar::from_little_endian(unsafe {
core::ptr::copy_nonoverlapping(
self.0[4..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
mem.assume_init()
- }.from_little_endian()
+ })
}
pub fn set_y(&mut self, x: f32) {
let x_le = x.to_little_endian();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
unsafe {
core::ptr::copy_nonoverlapping(
- &x_le as *const f32 as *const u8,
+ &x_le as *const _ as *const u8,
self.0[4..].as_mut_ptr(),
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
}
}
pub fn z(&self) -> f32 {
- let mut mem = core::mem::MaybeUninit::<f32>::uninit();
- unsafe {
+ let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ EndianScalar::from_little_endian(unsafe {
core::ptr::copy_nonoverlapping(
self.0[8..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
mem.assume_init()
- }.from_little_endian()
+ })
}
pub fn set_z(&mut self, x: f32) {
let x_le = x.to_little_endian();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
unsafe {
core::ptr::copy_nonoverlapping(
- &x_le as *const f32 as *const u8,
+ &x_le as *const _ as *const u8,
self.0[8..].as_mut_ptr(),
- core::mem::size_of::<f32>(),
+ core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
);
}
}
diff --git a/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs
index f0a709d..93ea6b2 100644
--- a/samples/rust_generated/my_game/sample/weapon_generated.rs
+++ b/samples/rust_generated/my_game/sample/weapon_generated.rs
@@ -19,8 +19,8 @@
impl<'a> flatbuffers::Follow<'a> for Weapon<'a> {
type Inner = Weapon<'a>;
#[inline]
- fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: flatbuffers::Table { buf, loc } }
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table::new(buf, loc) }
}
}
@@ -33,7 +33,7 @@
}
#[inline]
- pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
+ pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Weapon { _tab: table }
}
#[allow(unused_mut)]
@@ -60,11 +60,17 @@
#[inline]
pub fn name(&self) -> Option<&'a str> {
- self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
}
#[inline]
pub fn damage(&self) -> i16 {
- self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()}
}
}
diff --git a/samples/sample_binary.rs b/samples/sample_binary.rs
index 2f010b8..2fed9e5 100644
--- a/samples/sample_binary.rs
+++ b/samples/sample_binary.rs
@@ -19,7 +19,7 @@
// import the generated code
#[allow(dead_code, unused_imports)]
-#[allow(clippy::approx_constant)] // We use low precision PI as a default value.
+#[allow(clippy::all)]
mod rust_generated;
pub use rust_generated::my_game::sample::{Color, Equipment,
Monster, MonsterArgs,
@@ -122,10 +122,7 @@
// Get an element from the `inventory` FlatBuffer's `vector`.
assert!(monster.inventory().is_some());
let inv = monster.inventory().unwrap();
-
- // Note that this vector is returned as a slice, because direct access for
- // this type, a u8 vector, is safe on all platforms:
- let third_item = inv[2];
+ let third_item = inv.get(2);
assert_eq!(third_item, 2);
// Get and test the `weapons` FlatBuffers's `vector`.