Mark endian_scalar as unsafe. (#6588)

* Mark endian_scalar as unsafe.

Also
- removed the deprecated flexbuffer slice from example
- fixed some cargo warnings

* Assertions and read_scalar made unsafe

* Clippy lints

* Add to Safety

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2021-04-26 09:18:58 -04:00
committed by GitHub
parent 4ccc52c7a0
commit c24031c36b
20 changed files with 134 additions and 100 deletions

View File

@@ -1682,8 +1682,10 @@ mod roundtrip_scalars {
fn prop<T: PartialEq + ::std::fmt::Debug + Copy + flatbuffers::EndianScalar>(x: T) {
let mut buf = vec![0u8; ::std::mem::size_of::<T>()];
flatbuffers::emplace_scalar(&mut buf[..], x);
let y = flatbuffers::read_scalar(&buf[..]);
let y = unsafe {
flatbuffers::emplace_scalar(&mut buf[..], x);
flatbuffers::read_scalar(&buf[..])
};
assert_eq!(x, y);
}