It is surprisingly hard to find this in the docs. This might even be a two part question:
Are {integer}
and {float}
some sort of l
{integer}
is an integral value whose concrete type was not specified and has not been inferred by the compiler yet; the following code:
fn main() {
let x = 1;
let () = x;
}
Will result in the following error:
error[E0308]: mismatched types
--> :3:9
|
3 | let () = x;
| ^^ expected integral variable, found ()
|
= note: expected type `{integer}`
= note: found type `()`
The same would happen with a floating number:
fn main() {
let x = 1.0;
let () = x;
}
error[E0308]: mismatched types
--> :3:9
|
3 | let () = x;
| ^^ expected floating-point variable, found ()
|
= note: expected type `{float}`
= note: found type `()`
Because the compilation error caused by the invalid assignment let () = x
is thrown before the type inference can happen.
In other words, until the compilation reaches the type inference stage where an integer or a float without a concrete type specified would be recognized (e.g. based on function application) or assigned the default type, i32
for integers and f64
for floats, compilation errors will refer to it as an {integer}
or a {float}
.