Rust Output
println! prints a line and print! does not add a newline. Use {} for values and {:?} for debug output. Named arguments and width formats such as {:>5} and {:.2} control layout.
Example
let name = "Ada";
let pi = 3.14159;
println!("Hello {}", name);
println!("{name} has {n} items", n = 3);
println!("{:.2} [{:>5}] {:?}", pi, 42, vec![1, 2]);Result
Hello Ada Ada has 3 items 3.14 [ 42] [1, 2]
Exercise
Print with a placeholder.
println!("Hi {}", name);
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.