Println! What are the formats of macro

Time:2021-1-19
fn main() {
    Println! ("{}", 1); // default usage, print display
    Println! ("{: O}", 9); // octal
    Println! ("{: X}", 255); // hexadecimal lowercase
    Println! ("{: X}", 255); // hexadecimal uppercase
    Println! ("{: P}", & 0); // pointer
    Println! ("{: B}", 15); // binary
    Println! ("{: e}", 10000f32); // scientific count (lowercase)
    Println! ("{: e}", 10000f32); // scientific count (upper case)
    Println! ("{:?}", "test"); // print debug
    Println! ("{: #?}", ("test1", "test2")); // debug print with newline and indent
    Println! ("{a} {B} {B}", a = (x), B = (y)); // name the parameter
}

A comment for rust appears in the above code. Rust’s comments start with / / for line comments and start with / / for block comments/*and*/surround.

Rust’s notes have some special usages and functions. Follow up details.

This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

New JavaScript syntax “double question mark syntax” and “optional chain syntax”

Double question mark grammar Double question mark grammarThe concept is to return the value on the right when the value on the left is null or undefined let Form = undefined ?? true; //Form = true Alternative chain syntax ? optional chain //Optional chain let body = { value: { a: ‘123321’ } } let […]