mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-23 09:40:00 +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_; }
|
const Namespace *CurrentNameSpace() const { return cur_name_space_; }
|
||||||
|
|
||||||
// Determine if a Type needs a lifetime template parameter when used in Rust.
|
// Determine if a Type needs a lifetime template parameter when used in the
|
||||||
bool TypeNeedsLifetimeParameter(const Type &type) const {
|
// Rust builder args.
|
||||||
|
bool TableBuilderTypeNeedsLifetime(const Type &type) const {
|
||||||
switch (GetFullType(type)) {
|
switch (GetFullType(type)) {
|
||||||
case ftInteger:
|
case ftInteger:
|
||||||
case ftFloat:
|
case ftFloat:
|
||||||
case ftBool:
|
case ftBool:
|
||||||
case ftEnumKey:
|
case ftEnumKey:
|
||||||
case ftUnionKey: { return false; }
|
case ftUnionKey:
|
||||||
|
case ftUnionValue: { return false; }
|
||||||
default: { return true; }
|
default: { return true; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,7 +370,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TypeNeedsLifetimeParameter(field.value.type)) {
|
if (TableBuilderTypeNeedsLifetime(field.value.type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user