Default strings and vectors: Parser + Rust support (#6421)

* Fix tests.cpp

* Parser support for vector/string defaults

* tests and default empty vectors

* addressed comments

* Default strings and vectors for Rust

* Tested Rust more_defaults

* git-clang-format

* add more_defaults_test

* fixed vector default

* removed commented out code

* more unreachable

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2021-02-12 09:41:10 -05:00
committed by GitHub
parent 6af37e6729
commit 86401e078d
12 changed files with 403 additions and 100 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "flatbuffers"
version = "0.8.2"
version = "0.8.3"
edition = "2018"
authors = ["Robert Winslow <hello@rwinslow.com>", "FlatBuffers Maintainers"]
license = "Apache-2.0"

View File

@@ -29,6 +29,14 @@ use crate::primitives::*;
pub struct Vector<'a, T: 'a>(&'a [u8], usize, PhantomData<T>);
impl<'a, T:'a> Default for Vector<'a, T> {
fn default() -> Self {
// Static, length 0 vector.
// Note that derived default causes UB due to issues in read_scalar_at /facepalm.
Self(&[0; core::mem::size_of::<UOffsetT>()], 0, Default::default())
}
}
impl<'a, T> Debug for Vector<'a, T>
where
T: 'a + Follow<'a>,