let x = String::from("hello"); let x2 = x; println!("{x}");
let x = String::from("hello"); take_ownership(x); println!("{x}"); fn take_ownership(_name: String) { () }
let x = String::from("hello"); take_ownership(x.clone()); println!("{x}"); fn take_ownership(_name: String) { () }
let x = 1; println!("{x}"); println!("{x}");
Box::new()
let x = Box::new(1); take_ownership(x); println!("{x}"); fn take_ownership(_name: Box<i32>) { () }
let x = String::from("hello"); borrow(&x); println!("{x}"); fn borrow(_name: &String) { () }
let x = String::from("hello"); let x2 = &x; borrow(&x); println!("{x2}"); fn borrow(_name: &String) { () }
let mut x = String::from("hello"); let x2 = &x; borrow(&mut x); println!("{x2}"); fn borrow(_name: &mut String) { () }
let hello = "hello"; there(hello); fn there(hello2: &str) { println!("{hello2} there") }
&str
let hello = String::from("hello"); there(&hello); fn there(hello2: &str) { println!("{hello2} there") }