What is the printed output of the following code?
fn main() { let num: i32 = 5; { let num: i32 = num * 20; } println!("{}", num); }
True or false:
String slices are stored on the heap.
Will the following code compile?
fn main() { let s = String::from("hello"); print_string(s); dbg!(s); } fn print_string(s: String) { for i in s.chars() { println!("{}", i) } }
Consider the following code:
fn main() { let arr = &['1', '2', '3']; println!("{} {} {}", arr[0], arr[1], arr[2]) }
What is the type of arr?
Why does the following code refuse to compile?
fn main() { let mut string = String::from("String!"); let (x, y, z) = (&mut string, &mut string, &mut string); println!("{x}, {y}, {z}"); }