What do number literals with a suffix, like 0u8, mean in Rust?

前端 未结 1 1550
谎友^
谎友^ 2021-01-07 23:11

I\'m reading through The Rust Programming Language and have encountered this notation: 0u8.

let some_u8_value = 0u8;
match some_u8_value {
    1          


        
相关标签:
1条回答
  • 2021-01-07 23:41

    Suffixed Literals

    After searching, I've found this explanation in the same book:

    ... all number literals except the byte literal allow a type suffix, such as 57u8...

    So 0u8 is the number 0 as an unsigned 8-bit integer.

    These are referred to as "suffixed literals" and are discussed at length in Rust By Example.

    0 讨论(0)
提交回复
热议问题