3 ms·
A String can be returned like any other owned value; whether or not a &str can be returned depends on lifetimes, as it does with any other reference. Lifetimes
by brundolf 6y ago
A String can be returned like any other owned value; whether or not a &str can be returned depends on lifetimes, as it does with any other reference.
Lifetimes seem out of scope for this post, and the lifetimes story for strings isn't really strings-specific enough that it felt important to cover. There are other resources out there that thoroughly cover the topic of lifetimes; in fact I wrote a short summary myself in another post :)
https://www.brandons.me/blog/favorite-rust-function https://www.brandons.me/blog/favorite-rust-function