You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/literal-expr.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,8 @@ If the value does not fit in `u128`, the expression is rejected by the parser.
77
77
> **Note**: The final cast will truncate the value of the literal if it does not fit in the expression's type.
78
78
> There is a [lint check] named `overflowing_literals`, defaulting to `deny`, which rejects expressions where this occurs.
79
79
80
+
> **Note**: `-1i8`, for example, is an application of the [negation operator] to the literal expression `1i8`, not a single integer literal expression.
81
+
80
82
## Floating-point literal expressions
81
83
82
84
A floating-point literal expression consists of a single [FLOAT_LITERAL] token.
@@ -108,6 +110,8 @@ The value of the expression is determined from the string representation of the
108
110
109
111
* The string is converted to the expression's type as if by [`f32::from_str`] or [`f64::from_str`].
110
112
113
+
> **Note**: `-1.0`, for example, is an application of the [negation operator] to the literal expression `1.0`, not a single floating-point literal expression.
114
+
111
115
> **Note**: `inf` and `NaN` are not literal tokens.
112
116
> The [`f32::INFINITY`], [`f64::INFINITY`], [`f32::NAN`], and [`f64::NAN`] constants can be used instead of literal expressions.
113
117
> A literal large enough to be evaluated as infinite will trigger the `overflowing_literals` lint check.
@@ -119,6 +123,7 @@ The value of the expression is determined from the string representation of the
0 commit comments