diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-07-05 07:35:14 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-07-05 07:35:14 -0400 |
| commit | 08395a9a064c47ca48aebbf5f0e41a98efa0c8f6 (patch) | |
| tree | 01dbe002b31ddaa3bf32dd18c456a4aeb38e459a /src | |
| parent | f9f580936d81ed527115ae86375f69bb77723b1c (diff) | |
| parent | 4fc28c90f888d85b42a3015b6766ee6f3fb305f5 (diff) | |
| download | rust-08395a9a064c47ca48aebbf5f0e41a98efa0c8f6.tar.gz rust-08395a9a064c47ca48aebbf5f0e41a98efa0c8f6.zip | |
Rollup merge of #26785 - tshepang:inference, r=steveklabnik
…at and integer types
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/reference.md | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 650e1d5541e..6fc46c764f5 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -338,12 +338,16 @@ type of the literal. The integer suffix must be the name of one of the integral types: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `isize`, or `usize`. -The type of an _unsuffixed_ integer literal is determined by type inference. -If an integer type can be _uniquely_ determined from the surrounding program -context, the unsuffixed integer literal has that type. If the program context -underconstrains the type, it defaults to the signed 32-bit integer `i32`; if -the program context overconstrains the type, it is considered a static type -error. +The type of an _unsuffixed_ integer literal is determined by type inference: + +* If an integer type can be _uniquely_ determined from the surrounding + program context, the unsuffixed integer literal has that type. + +* If the program context underconstrains the type, it defaults to the + signed 32-bit integer `i32`. + +* If the program context overconstrains the type, it is considered a + static type error. Examples of integer literals of various forms: @@ -371,12 +375,17 @@ The suffix forcibly sets the type of the literal. There are two valid _floating-point suffixes_, `f32` and `f64` (the 32-bit and 64-bit floating point types), which explicitly determine the type of the literal. -The type of an _unsuffixed_ floating-point literal is determined by type -inference. If a floating-point type can be _uniquely_ determined from the -surrounding program context, the unsuffixed floating-point literal has that type. -If the program context underconstrains the type, it defaults to double-precision `f64`; -if the program context overconstrains the type, it is considered a static type -error. +The type of an _unsuffixed_ floating-point literal is determined by +type inference: + +* If a floating-point type can be _uniquely_ determined from the + surrounding program context, the unsuffixed floating-point literal + has that type. + +* If the program context underconstrains the type, it defaults to `f64`. + +* If the program context overconstrains the type, it is considered a + static type error. Examples of floating-point literals of various forms: |
