Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Ownership error
I 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