Move

fn main() {

    let s1 = String::from("hello");
    let s2 = s1;

    println!("s2 is {}", s2);

    // Uncomment to see the error
    // println!("s1 is {}", s1);
    // s1 is no more valid  ^^

} // Only heap of s2 will be dropped
  • No double free error
String in memory