diff options
author | jean-airoldie <25088801+jean-airoldie@users.noreply.github.com> | 2019-04-26 21:40:10 -0400 |
---|---|---|
committer | Robert <rw@users.noreply.github.com> | 2019-04-26 18:40:10 -0700 |
commit | e5b6125fa2ceaae7ba5c1c46bf311b2bae6de289 (patch) | |
tree | e6a08b0104381c0e8610d34d893a21c8d358b208 /rust | |
parent | ac14c8906f9f5525846cb5fee2eaa3fc614fad1d (diff) | |
download | flatbuffers-e5b6125fa2ceaae7ba5c1c46bf311b2bae6de289.tar.gz flatbuffers-e5b6125fa2ceaae7ba5c1c46bf311b2bae6de289.tar.bz2 flatbuffers-e5b6125fa2ceaae7ba5c1c46bf311b2bae6de289.zip |
Added common rust traits to FlatBufferBuilder (#5307)
* Added Clone, Debug and Default
Diffstat (limited to 'rust')
-rw-r--r-- | rust/flatbuffers/src/builder.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/flatbuffers/src/builder.rs b/rust/flatbuffers/src/builder.rs index f755a498..68cb434b 100644 --- a/rust/flatbuffers/src/builder.rs +++ b/rust/flatbuffers/src/builder.rs @@ -40,6 +40,7 @@ struct FieldLoc { /// FlatBufferBuilder builds a FlatBuffer through manipulating its internal /// state. It has an owned `Vec<u8>` that grows as needed (up to the hardcoded /// limit of 2GiB, which is set by the FlatBuffers format). +#[derive(Clone, Debug)] pub struct FlatBufferBuilder<'fbb> { owned_buf: Vec<u8>, head: usize, @@ -638,3 +639,9 @@ fn padding_bytes(buf_size: usize, scalar_size: usize) -> usize { // ((!buf_size) + 1) & (scalar_size - 1) (!buf_size).wrapping_add(1) & (scalar_size.wrapping_sub(1)) } + +impl<'fbb> Default for FlatBufferBuilder<'fbb> { + fn default() -> Self { + Self::new_with_capacity(0) + } +} |