Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions goldens/rust/basic_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl core::fmt::Debug for Universe<'_> {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_universe_unchecked`.
pub fn root_as_universe(buf: &[u8]) -> Result<Universe, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Universe>(buf)
}
#[inline]
Expand All @@ -254,7 +254,7 @@ pub fn root_as_universe(buf: &[u8]) -> Result<Universe, flatbuffers::InvalidFlat
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_universe_unchecked`.
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Universe>(buf)
}
#[inline]
Expand Down Expand Up @@ -287,14 +287,14 @@ pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe {
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
unsafe { flatbuffers::root_unchecked::<Universe>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe {
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
}
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions rust/flexbuffers/src/builder/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a> MapBuilder<'a> {
///
/// This will panic (in debug mode) if `key` contains internal nulls.
#[inline]
pub fn start_vector(&mut self, key: &str) -> VectorBuilder {
pub fn start_vector(&mut self, key: &str) -> VectorBuilder<'_> {
// Push the key that refers to this nested vector.
self.builder.push_key(key);
// Nested vector.
Expand All @@ -58,7 +58,7 @@ impl<'a> MapBuilder<'a> {
///
/// This will panic (in debug mode) if `key` contains internal nulls.
#[inline]
pub fn start_map(&mut self, key: &str) -> MapBuilder {
pub fn start_map(&mut self, key: &str) -> MapBuilder<'_> {
// Push the key that refers to this nested vector.
self.builder.push_key(key);
// Nested map.
Expand Down
4 changes: 2 additions & 2 deletions rust/flexbuffers/src/builder/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> VectorBuilder<'a> {
}
/// Starts a nested vector that will be pushed onto this vector when it is dropped.
#[inline]
pub fn start_vector(&mut self) -> VectorBuilder {
pub fn start_vector(&mut self) -> VectorBuilder<'_> {
let start = Some(self.builder.values.len());
VectorBuilder {
builder: self.builder,
Expand All @@ -45,7 +45,7 @@ impl<'a> VectorBuilder<'a> {
}
/// Starts a nested map that will be pushed onto this vector when it is dropped.
#[inline]
pub fn start_map(&mut self) -> MapBuilder {
pub fn start_map(&mut self) -> MapBuilder<'_> {
let start = Some(self.builder.values.len());
MapBuilder {
builder: self.builder,
Expand Down
8 changes: 4 additions & 4 deletions samples/rust_generated/my_game/sample/monster_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl MonsterT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_monster_unchecked`.
pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Monster>(buf)
}
#[inline]
Expand All @@ -417,7 +417,7 @@ pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbu
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_monster_unchecked`.
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Monster>(buf)
}
#[inline]
Expand Down Expand Up @@ -450,14 +450,14 @@ pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::root_unchecked::<Monster>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
#[inline]
Expand Down
8 changes: 4 additions & 4 deletions src/idl_gen_rust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ class RustGenerator : public BaseGenerator {
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
code_ +=
"pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) "
"-> Result<{{STRUCT_TY}}, flatbuffers::InvalidFlatbuffer> {";
"-> Result<{{STRUCT_TY}}<'_>, flatbuffers::InvalidFlatbuffer> {";
code_ += " flatbuffers::root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
code_ += "#[inline]";
Expand All @@ -2430,7 +2430,7 @@ class RustGenerator : public BaseGenerator {
code_ += "/// `size_prefixed_root_as_{{STRUCT_FN}}_unchecked`.";
code_ +=
"pub fn size_prefixed_root_as_{{STRUCT_FN}}"
"(buf: &[u8]) -> Result<{{STRUCT_TY}}, "
"(buf: &[u8]) -> Result<{{STRUCT_TY}}<'_>, "
"flatbuffers::InvalidFlatbuffer> {";
code_ += " flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
Expand Down Expand Up @@ -2480,7 +2480,7 @@ class RustGenerator : public BaseGenerator {
" `{{STRUCT_TY}}`.";
code_ +=
"pub unsafe fn root_as_{{STRUCT_FN}}_unchecked"
"(buf: &[u8]) -> {{STRUCT_TY}} {";
"(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
code_ += " unsafe { flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
code_ += "}";
code_ += "#[inline]";
Expand All @@ -2493,7 +2493,7 @@ class RustGenerator : public BaseGenerator {
" size prefixed `{{STRUCT_TY}}`.";
code_ +=
"pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}"
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}} {";
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
code_ +=
" unsafe { flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>"
"(buf) }";
Expand Down
8 changes: 4 additions & 4 deletions tests/arrays_test/my_game/example/array_table_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl ArrayTableT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_array_table_unchecked`.
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<ArrayTable>(buf)
}
#[inline]
Expand All @@ -159,7 +159,7 @@ pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable, flatbuffers::Invali
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_array_table_unchecked`.
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<ArrayTable>(buf)
}
#[inline]
Expand Down Expand Up @@ -192,14 +192,14 @@ pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable {
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
unsafe { flatbuffers::root_unchecked::<ArrayTable>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable {
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
}
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
Expand Down
8 changes: 4 additions & 4 deletions tests/monster_test/my_game/example/monster_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ impl MonsterT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_monster_unchecked`.
pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Monster>(buf)
}
#[inline]
Expand All @@ -1945,7 +1945,7 @@ pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbu
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_monster_unchecked`.
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Monster>(buf)
}
#[inline]
Expand Down Expand Up @@ -1978,14 +1978,14 @@ pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::root_unchecked::<Monster>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
pub const MONSTER_IDENTIFIER: &str = "MONS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ impl MonsterT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_monster_unchecked`.
pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Monster>(buf)
}
#[inline]
Expand All @@ -2172,7 +2172,7 @@ pub fn root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbu
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_monster_unchecked`.
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Monster>(buf)
}
#[inline]
Expand Down Expand Up @@ -2205,14 +2205,14 @@ pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::root_unchecked::<Monster>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster {
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
pub const MONSTER_IDENTIFIER: &str = "MONS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ impl ScalarStuffT {
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_scalar_stuff_unchecked`.
pub fn root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff, flatbuffers::InvalidFlatbuffer> {
pub fn root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<ScalarStuff>(buf)
}
#[inline]
Expand All @@ -961,7 +961,7 @@ pub fn root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff, flatbuffers::Inva
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_scalar_stuff_unchecked`.
pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff, flatbuffers::InvalidFlatbuffer> {
pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<ScalarStuff>(buf)
}
#[inline]
Expand Down Expand Up @@ -994,14 +994,14 @@ pub fn size_prefixed_root_as_scalar_stuff_with_opts<'b, 'o>(
/// Assumes, without verification, that a buffer of bytes contains a ScalarStuff and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `ScalarStuff`.
pub unsafe fn root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff {
pub unsafe fn root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
unsafe { flatbuffers::root_unchecked::<ScalarStuff>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ScalarStuff and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ScalarStuff`.
pub unsafe fn size_prefixed_root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff {
pub unsafe fn size_prefixed_root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<ScalarStuff>(buf) }
}
pub const SCALAR_STUFF_IDENTIFIER: &str = "NULL";
Expand Down