Rust/format
format!macro- The
format!macro creates a formatted string by combining text with values - Part of Rust's standard library macro family for string formatting
Overview
Syntax
Format Specifiers
{}- Default formatting (usesDisplaytrait){:?}- Debug formatting (usesDebugtrait){:#?}- Pretty-printed debug formatting{0}- Positional argument (0-indexed){name}- Named argument{:width}- Minimum width{:0width}- Zero-padded with minimum width{:.precision}- Floating-point precision{:x}- Hexadecimal formatting (lowercase){:X}- Hexadecimal formatting (uppercase){:o}- Octal formatting{:b}- Binary formatting
Examples
Related Macros
- Rust/println - Print formatted text to stdout with newline
- Rust/print - Print formatted text to stdout
- Rust/eprintln - Print formatted text to stderr with newline
- Rust/eprint - Print formatted text to stderr
- Rust/write - Write formatted text to a writer
- Rust/writeln - Write formatted text to a writer with newline
Traits Used
Performance
Related
- Rust/Macro - General macro concept in Rust
- Rust/String - String type in Rust
- Rust/std/fmt - Formatting module in standard library
- Rust/Book/TRPL - The Rust Programming Language book
- The