expression
Sign, alternate prefixes and zero padding
The plus flag requests a sign for positive numbers; alternate formatting can supply a radix prefix. Numeric zero padding keeps sign and prefix ahead of the padding digits. Expected stdout (not executed): +7 0x002a -0007 Common mistake: Manually inserting zeros before the minus sign.
Formal Syntax & Structure
rust syntaxrust
{:+}; {:#x}; {:06}Working Example
Example Snippetrust
fn main() { println!("{:+} {:#06x} {:05}", 7, 42, -7);}