Skip to content

Commit 9f794ee

Browse files
author
Dallas Marlow
committed
fix(rust: builder): add lifetime bounds to finish methods
1 parent 4c0eecd commit 9f794ee

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

rust/flatbuffers/src/builder.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
517517
/// internal state of the FlatBufferBuilder as `finished`. Afterwards,
518518
/// users can call `finished_data` to get the resulting data.
519519
#[inline]
520-
pub fn finish_size_prefixed<T>(&mut self, root: WIPOffset<T>, file_identifier: Option<&str>) {
520+
pub fn finish_size_prefixed<T>(&mut self, root: WIPOffset<T>, file_identifier: Option<&str>)
521+
where
522+
T: 'fbb,
523+
{
521524
self.finish_with_opts(root, file_identifier, true);
522525
}
523526

@@ -526,15 +529,21 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
526529
/// FlatBufferBuilder as `finished`. Afterwards, users can call
527530
/// `finished_data` to get the resulting data.
528531
#[inline]
529-
pub fn finish<T>(&mut self, root: WIPOffset<T>, file_identifier: Option<&str>) {
532+
pub fn finish<T>(&mut self, root: WIPOffset<T>, file_identifier: Option<&str>)
533+
where
534+
T: 'fbb,
535+
{
530536
self.finish_with_opts(root, file_identifier, false);
531537
}
532538

533539
/// Finalize the FlatBuffer by: aligning it and marking the internal state
534540
/// of the FlatBufferBuilder as `finished`. Afterwards, users can call
535541
/// `finished_data` to get the resulting data.
536542
#[inline]
537-
pub fn finish_minimal<T>(&mut self, root: WIPOffset<T>) {
543+
pub fn finish_minimal<T>(&mut self, root: WIPOffset<T>)
544+
where
545+
T: 'fbb,
546+
{
538547
self.finish_with_opts(root, None, false);
539548
}
540549

@@ -689,7 +698,9 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
689698
root: WIPOffset<T>,
690699
file_identifier: Option<&str>,
691700
size_prefixed: bool,
692-
) {
701+
) where
702+
T: 'fbb,
703+
{
693704
self.assert_not_finished("buffer cannot be finished when it is already finished");
694705
self.assert_not_nested(
695706
"buffer cannot be finished when a table or vector is under construction",

0 commit comments

Comments
 (0)