- println
- eprint
- eprintln
- dbg
- format
Rust and print
- format! returns formatted string
examples/intro/print/src/main.rs
#[allow(clippy::print_with_newline)] fn main() { let fname = "Foo"; let lname = "Bar"; println!("{} {}", fname, lname); println!("{fname} {lname}"); print!("{fname} {lname}\n"); eprintln!("error in {} {}", fname, lname); eprint!("error in {} {}\n", fname, lname); let full_name = format!("{fname} {lname}"); println!("{full_name}"); dbg!(full_name); }
Foo Bar Foo Bar Foo Bar error in Foo Bar error in Foo Bar Foo Bar [examples/intro/print.rs:14] full_name = "Foo Bar"