DEV Community

Discussion on: Rust impl Trait For Programmers

Collapse
 
josephpenafiel profile image
Joseph Penafiel • Edited

Hello, thank you for sharing your knowledge. I’m learning rust, and I see that you were able to return string slices (which are references) from the make_value function. Why did it work without having to annotate lifetime parameters? Does “impl Display” puts them implicitly?

Collapse
 
hertz4 profile image
Sam Pagenkopf

I found this error message that explains things well:
github.com/rust-lang/rust/issues/5...

The lifetime is 'static by default, but writing Display + '_ tells the compiler to infer a shorter-lasting lifetime.