Skip to content

Commit 4fc28c9

Browse files
committed
reference: improve readability of type inference explanations for float and integer types
1 parent 912ab64 commit 4fc28c9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/doc/reference.md

+21-12
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,16 @@ type of the literal. The integer suffix must be the name of one of the
338338
integral types: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`,
339339
`isize`, or `usize`.
340340

341-
The type of an _unsuffixed_ integer literal is determined by type inference.
342-
If an integer type can be _uniquely_ determined from the surrounding program
343-
context, the unsuffixed integer literal has that type. If the program context
344-
underconstrains the type, it defaults to the signed 32-bit integer `i32`; if
345-
the program context overconstrains the type, it is considered a static type
346-
error.
341+
The type of an _unsuffixed_ integer literal is determined by type inference:
342+
343+
* If an integer type can be _uniquely_ determined from the surrounding
344+
program context, the unsuffixed integer literal has that type.
345+
346+
* If the program context underconstrains the type, it defaults to the
347+
signed 32-bit integer `i32`.
348+
349+
* If the program context overconstrains the type, it is considered a
350+
static type error.
347351

348352
Examples of integer literals of various forms:
349353

@@ -371,12 +375,17 @@ The suffix forcibly sets the type of the literal. There are two valid
371375
_floating-point suffixes_, `f32` and `f64` (the 32-bit and 64-bit floating point
372376
types), which explicitly determine the type of the literal.
373377

374-
The type of an _unsuffixed_ floating-point literal is determined by type
375-
inference. If a floating-point type can be _uniquely_ determined from the
376-
surrounding program context, the unsuffixed floating-point literal has that type.
377-
If the program context underconstrains the type, it defaults to double-precision `f64`;
378-
if the program context overconstrains the type, it is considered a static type
379-
error.
378+
The type of an _unsuffixed_ floating-point literal is determined by
379+
type inference:
380+
381+
* If a floating-point type can be _uniquely_ determined from the
382+
surrounding program context, the unsuffixed floating-point literal
383+
has that type.
384+
385+
* If the program context underconstrains the type, it defaults to `f64`.
386+
387+
* If the program context overconstrains the type, it is considered a
388+
static type error.
380389

381390
Examples of floating-point literals of various forms:
382391

0 commit comments

Comments
 (0)