mutable参照は所有権を移動する

サンプルコード

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

// s2はmutable 参照
let s2 = &mut s1;
print_type_name_of(s2);
s2.push_str(" world");

/*
error[E0382]: borrow of moved value: `s2`
  |
3 |     let s2 = &mut s1;
  |         -- move occurs because `s2` has type `&mut std::string::String`, which does not implement the `Copy` trait
4 |     print_type_name_of(s2);
  |                        -- value moved here
5 |     s2.push_str(" world");
  |     ^^ value borrowed here after move
*/

Memo: print_type_name_of

fn print_type_name_of<T>(_val: T) {
    let name = std::any::type_name::<T>();
    println!("{}", name);
}