Skip to content

Commit 63f68ee

Browse files
authored
Added an additional example of lifetime elision
The question of how did this behave showed up in a rust-for-linux code review, and it would have been easier to explain had this example been present.
1 parent 41ccb0e commit 63f68ee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lifetime-elision.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ fn get_mut2<'a>(&'a mut self) -> &'a mut dyn T; // expanded
4848
fn args1<T: ToCStr>(&mut self, args: &[T]) -> &mut Command; // elided
4949
fn args2<'a, 'b, T: ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command; // expanded
5050

51+
fn other_args<'a>(arg: &T) -> &'a str; // elided
52+
fn other_args<'a, 'b>(arg: &'b T) -> &'a str; // expanded
53+
5154
fn new1(buf: &mut [u8]) -> Thing<'_>; // elided - preferred
5255
fn new2(buf: &mut [u8]) -> Thing; // elided
5356
fn new3<'a>(buf: &'a mut [u8]) -> Thing<'a>; // expanded

0 commit comments

Comments
 (0)