Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Concatenation String with String (clone)

  • clone
fn main() {
    let string1 = String::from("Apple");
    let string2 = String::from("Banana");

    let text = string1.clone() + &string2; // we move strin1 and then copy the content of string2
    println!("{}", text);
    println!("{}", string2);
    println!("{}", string1);
}
AppleBanana
Banana
Apple