Merge pull request #415 from Nangos/patch-4

Update ch03-02-data-types.md
This commit is contained in:
KaiserY 2020-06-26 13:00:06 +08:00 committed by GitHub
commit 638c2624fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,11 +58,11 @@ error[E0282]: type annotations needed
| 数字字面值 | 例子 |
|------------------|---------------|
| Decimal | `98_222` |
| Hex | `0xff` |
| Octal | `0o77` |
| Binary | `0b1111_0000` |
| Byte (`u8` only) | `b'A'` |
| Decimal (十进制) | `98_222` |
| Hex (十六进制) | `0xff` |
| Octal (八进制) | `0o77` |
| Binary (二进制) | `0b1111_0000` |
| Byte (单字节字符)(仅限于`u8`) | `b'A'` |
那么该使用哪种类型的数字呢如果拿不定主意Rust 的默认类型通常就很好,数字类型默认是 `i32`:它通常是最快的,甚至在 64 位系统上也是。`isize` 或 `usize` 主要作为某些集合的索引。
@ -293,4 +293,4 @@ ch02-00-guessing-game-tutorial.html#comparing-the-guess-to-the-secret-number
[control-flow]: ch03-05-control-flow.html#control-flow
[strings]: ch08-02-strings.html#storing-utf-8-encoded-text-with-strings
[unrecoverable-errors-with-panic]: ch09-01-unrecoverable-errors-with-panic.html
[wrapping]: ../std/num/struct.Wrapping.html
[wrapping]: ../std/num/struct.Wrapping.html