Skip to content

Commit e5b6125

Browse files
jean-airoldierw
authored andcommitted
Added common rust traits to FlatBufferBuilder (google#5307)
* Added Clone, Debug and Default
1 parent ac14c89 commit e5b6125

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rust/flatbuffers/src/builder.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct FieldLoc {
4040
/// FlatBufferBuilder builds a FlatBuffer through manipulating its internal
4141
/// state. It has an owned `Vec<u8>` that grows as needed (up to the hardcoded
4242
/// limit of 2GiB, which is set by the FlatBuffers format).
43+
#[derive(Clone, Debug)]
4344
pub struct FlatBufferBuilder<'fbb> {
4445
owned_buf: Vec<u8>,
4546
head: usize,
@@ -638,3 +639,9 @@ fn padding_bytes(buf_size: usize, scalar_size: usize) -> usize {
638639
// ((!buf_size) + 1) & (scalar_size - 1)
639640
(!buf_size).wrapping_add(1) & (scalar_size.wrapping_sub(1))
640641
}
642+
643+
impl<'fbb> Default for FlatBufferBuilder<'fbb> {
644+
fn default() -> Self {
645+
Self::new_with_capacity(0)
646+
}
647+
}

0 commit comments

Comments
 (0)