Commit e5b6125f authored by jean-airoldie's avatar jean-airoldie Committed by Robert

Added common rust traits to FlatBufferBuilder (#5307)

* Added Clone, Debug and Default
parent ac14c890
...@@ -40,6 +40,7 @@ struct FieldLoc { ...@@ -40,6 +40,7 @@ struct FieldLoc {
/// FlatBufferBuilder builds a FlatBuffer through manipulating its internal /// FlatBufferBuilder builds a FlatBuffer through manipulating its internal
/// state. It has an owned `Vec<u8>` that grows as needed (up to the hardcoded /// 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). /// limit of 2GiB, which is set by the FlatBuffers format).
#[derive(Clone, Debug)]
pub struct FlatBufferBuilder<'fbb> { pub struct FlatBufferBuilder<'fbb> {
owned_buf: Vec<u8>, owned_buf: Vec<u8>,
head: usize, head: usize,
...@@ -638,3 +639,9 @@ fn padding_bytes(buf_size: usize, scalar_size: usize) -> usize { ...@@ -638,3 +639,9 @@ fn padding_bytes(buf_size: usize, scalar_size: usize) -> usize {
// ((!buf_size) + 1) & (scalar_size - 1) // ((!buf_size) + 1) & (scalar_size - 1)
(!buf_size).wrapping_add(1) & (scalar_size.wrapping_sub(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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment