With the old-style code, the test fails with a borrow-checker error:
```
#[inline]
pub fn name(&'a self) -> &'a str {
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()
}
```
```
error[E0597]: `e` does not live long enough
--> tests/integration_test.rs:273:57
|
273 | let enemy_of_my_enemy = monster.enemy().map(|e| e.name());
| ^ - `e` dropped here while still borrowed
| |
| borrowed value does not live long enough
274 | assert_eq!(enemy_of_my_enemy, Some("Fred"));
275 | }
| - borrowed value needs to live until here
```
This is a port of FlatBuffers to Rust. It provides code generation and a
runtime library derived from the C++ implementation. It utilizes the
Rust type system to provide safe and fast traversal of FlatBuffers data.
There are 188 tests, including many fuzz tests of roundtrips for various
serialization scenarios. Initial benchmarks indicate that the canonical
example payload can be written in ~700ns, and traversed in ~100ns.
Rustaceans may be interested in the Follow, Push, and SafeSliceAccess
traits. These traits lift traversals, reads, writes, and slice accesses
into the type system, providing abstraction with no runtime penalty.