mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 20:31:23 +00:00
rust: more builder lifetimes predicates (#4923)
This commit is contained in:
@@ -345,14 +345,16 @@ class RustGenerator : public BaseGenerator {
|
||||
|
||||
const Namespace *CurrentNameSpace() const { return cur_name_space_; }
|
||||
|
||||
// Determine if a Type needs a lifetime template parameter when used in Rust.
|
||||
bool TypeNeedsLifetimeParameter(const Type &type) const {
|
||||
// Determine if a Type needs a lifetime template parameter when used in the
|
||||
// Rust builder args.
|
||||
bool TableBuilderTypeNeedsLifetime(const Type &type) const {
|
||||
switch (GetFullType(type)) {
|
||||
case ftInteger:
|
||||
case ftFloat:
|
||||
case ftBool:
|
||||
case ftEnumKey:
|
||||
case ftUnionKey: { return false; }
|
||||
case ftUnionKey:
|
||||
case ftUnionValue: { return false; }
|
||||
default: { return true; }
|
||||
}
|
||||
}
|
||||
@@ -368,7 +370,7 @@ class RustGenerator : public BaseGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TypeNeedsLifetimeParameter(field.value.type)) {
|
||||
if (TableBuilderTypeNeedsLifetime(field.value.type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user