Ownership error
⚓ Rust 📅 2025-09-17 👤 surdeus 👁️ 10I have a function that takes one parameter, a string and returns a string reference of the clone of that string parameter. The binary however doesn't compile. The debugger requests that I change the string reference. What Im I fundamentally missing in this setup. Here is the code
fn taker (S:String) -> &String {
let c = S.clone();
&c
}
fn main () {
let V = taker("Value".to_string());
println!(".. {:?}",V);
}
4 posts - 4 participants
🏷️ Rust_feed
