- clone
Rust clone a String
- In some cases what we will want is to copy the content of the variable.
- For this we can use the clone method.
examples/ownership/string-clone/src/main.rs
fn main() { let x = String::from("Foo Bar"); println!("{x}"); let y = x.clone(); println!("{y}"); println!("{x}"); }