Println! macro
In Rust, println! is a standard-library macro that formats arguments and writes the resulting text followed by a newline to standard output.
Learn Rust in a Month of Lunches
The println! macro formats its arguments and writes the resulting text followed by a newline to standard output.
- How it is used
- Uses formatted printing to display messages and computed values in beginner Rust programs.
- How deep it goes
- Explains placeholders, formatting options, escapes, and alignment through examples, without detailing macro internals.
- Examples
- Uses greetings, multiplication results, compiler errors, pointer addresses, and aligned city names to illustrate printing.
- What you can do after
- Apply it in Rust programs to print values with placeholders and choose suitable formatting.
Read how Learn Rust in a Month of Lunches explains println! macro →
Rust in Action: Systems programming concepts and techniques
println! is Rust's standard macro for printing formatted output followed by a newline.
- How it is used
- Prints fixed or formatted values to the console while introducing Rust’s macro syntax.
- How deep it goes
- Explains macro notation, stdout, placeholders, and type handling, but treats macros as function-like rather than exposing expansion internals.
- Examples
- Demonstrates greetings in three languages, iterated strings, formatted placeholders, and CSV-processing output.
- What you can do after
- Apply it via Rust syntax to print messages and formatted values during small programs and data-processing tasks.
Read how Rust in Action: Systems programming concepts and techniques explains println! macro →
Also covered in
What to know first
- inheritanceInheritance is a mechanism in which a derived type or descendant element receives properties or behavior from a parent, subject to rules that may allow specialization or overriding.
- RustRust is a statically typed systems programming language designed for performance, concurrency, and memory safety without requiring garbage collection.
Related concepts
- Displayuses · Display is Rust’s standard formatting trait for producing a user-facing textual representation of a value.
- dbg! macroalternative to · The Rust dbg! macro evaluates an expression, prints debugging information including its source and value, and returns the expression’s value.
- Debuguses · Debug is a Rust standard-library formatting trait for producing programmer-oriented representations of values.
- format! macroalternative to · format! is a Rust macro that interpolates values according to a format string and returns the result as a String.
- macrokind of · A macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
- standard outputuses · Standard output is a process's conventional stream for writing ordinary program output, which may be directed to a terminal, file, pipe, or other destination.
Questions about println! macro
What is println! macro?
In Rust, println! is a standard-library macro that formats arguments and writes the resulting text followed by a newline to standard output.
Which Manning books explain println! macro?
Learn Rust in a Month of Lunches and Rust in Action: Systems programming concepts and techniques.
What should I know before learning println! macro?
Manning books that teach println! macro usually introduce inheritance and Rust first.
What is the difference between println! macro and dbg! macro?
In Rust, println! is a standard-library macro that formats arguments and writes the resulting text followed by a newline to standard output. The Rust dbg! macro evaluates an expression, prints debugging information including its source and value, and returns the expression’s value.
What is println! macro a kind of?
Println! macro is a kind of macro. A macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

