mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 10:08:52 +00:00
Rust Object API (#6070)
* inital commit of rust object api * Required fields support. * clang fallthrough * Fix unused variables * just don't fall through * remove comment * s/panic/unreachable * Tests for object API * Added defaults * deleted unintentionally added files and updated .bat file * fix bat file * clang format * Cargo clippy checks * remove commented out code * clippy allows * Remove matches! macro since we're not yet at Rust v1.42 * install clippy in RustTest.sh * move line Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -37,6 +37,16 @@ macro_rules! make_test {
|
||||
assert_eq!(s.$just(), $zero);
|
||||
assert_eq!(s.$default(), $fortytwo);
|
||||
assert_eq!(s.$maybe(), None);
|
||||
|
||||
// Same for object API
|
||||
let s = flatbuffers::root::<ScalarStuff>(builder.finished_data()).unwrap().unpack();
|
||||
assert_eq!(s.$just, $five);
|
||||
assert_eq!(s.$default, $five);
|
||||
assert_eq!(s.$maybe, Some($five));
|
||||
let s = flatbuffers::root::<ScalarStuff>(&[0; 8]).unwrap().unpack();
|
||||
assert_eq!(s.$just, $zero);
|
||||
assert_eq!(s.$default, $fortytwo);
|
||||
assert_eq!(s.$maybe, None);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user