diff options
author | Matt Mastracci <matthew@mastracci.com> | 2018-09-28 21:11:05 -0600 |
---|---|---|
committer | Robert <rw@users.noreply.github.com> | 2018-09-28 20:11:05 -0700 |
commit | bf871ffd7f910601483b4eec5e4fbeb29f29a17b (patch) | |
tree | 159cd31b754852227a38d1c2c8648c13d3bacb5c /src/idl_gen_rust.cpp | |
parent | a89be8739c462b47d59e1364e3e2dc8096806400 (diff) | |
download | flatbuffers-bf871ffd7f910601483b4eec5e4fbeb29f29a17b.tar.gz flatbuffers-bf871ffd7f910601483b4eec5e4fbeb29f29a17b.tar.bz2 flatbuffers-bf871ffd7f910601483b4eec5e4fbeb29f29a17b.zip |
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
```
Diffstat (limited to 'src/idl_gen_rust.cpp')
-rw-r--r-- | src/idl_gen_rust.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index 1ca6254a..48858bda 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -1263,7 +1263,7 @@ class RustGenerator : public BaseGenerator { GenComment(field.doc_comment, " "); code_ += " #[inline]"; - code_ += " pub fn {{FIELD_NAME}}(&'a self) -> {{RETURN_TYPE}} {"; + code_ += " pub fn {{FIELD_NAME}}(&self) -> {{RETURN_TYPE}} {"; code_ += " {{FUNC_BODY}}"; code_ += " }"; |