Why can't we store returned value of a function in a variable if one of the parameters goes out of scope

⚓ Rust    📅 2026-05-12    👤 surdeus    👁️ 1      

surdeus

Screenshot 2026-05-13 at 12.17.12 AM

Here, why cant we store returned value in longest so that even if str2 goes out scope we can still use longest and what is the way around these situations.

Because there can be many cases where I may need the returned value after it goes out of scope

4 posts - 4 participants

Read full topic

🏷️ Rust_feed