Rust print: Difference between revisions
From wikinotes
(Created page with " = println = <blockquote> == String Interpolation == <blockquote> <syntaxhighlight lang="rust"> println!("abc"); </syntaxhighlight> </blockquote><!-- String Interpolation --> == Formatting == <blockquote> <syntaxhighlight lang="rust"> println!("Hello, {}", "alex"); println!("{0}, {0}, see {1}?", "alex", "movie"); println!("{person}, see {thing}?", person="alex", thing="movie"); </syntaxhighlight> </blockquote><!-- Formatting --> == Type Formatting == <blockquote> <synt...") |
(No difference)
|
Revision as of 21:15, 6 February 2023
println
String Interpolation
println!("abc");Formatting
println!("Hello, {}", "alex"); println!("{0}, {0}, see {1}?", "alex", "movie"); println!("{person}, see {thing}?", person="alex", thing="movie");Type Formatting
// formatting println!("{:>4}", 2) // " 2" right align println!("{:0>4}", 2) // "0002" right align, padded w/ zeros println!("{var:>4}", var="boo") // " boo" right align // type formatting println!("{:X}", 1234) // "4D2" hex println!("{:o}", 1234) // "2322" octal