macro

println! — Print a line to standard output

Write a formatted line to stdout. It appends a newline; with no arguments it prints a blank line. The format template is checked during compilation, but values can be computed at runtime. Expression result: (). Expected result (not executed): stdout: 'Items: 4\n'; no stderr. Common mistake: Using a dynamically built String as the format template. Use println!("{}", message) instead.

Formal Syntax & Structure

rust syntaxrust
println!("format string", arguments...)

Working Example

Example Snippetrust
fn main() {    let items = 4;    println!("Items: {items}");}
Rust Reference