Remove lifetime specifier on table getter methods (#4949)

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 commit is contained in:
Matt Mastracci
2018-09-28 21:11:05 -06:00
committed by Robert
parent a89be8739c
commit bf871ffd7f
5 changed files with 84 additions and 67 deletions

View File

@@ -184,7 +184,7 @@ impl<'a> TableInNestedNS<'a> {
pub const VT_FOO: flatbuffers::VOffsetT = 4;
#[inline]
pub fn foo(&'a self) -> i32 {
pub fn foo(&self) -> i32 {
self._tab.get::<i32>(TableInNestedNS::VT_FOO, Some(0)).unwrap()
}
}