3 ms·
This is a great intro, but clarifying one more thing might be useful: how do you return a string?
by skybrian 6y ago
This is a great intro, but clarifying one more thing might be useful: how do you return a string?
- brundolf 6y agoA 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