Closed
Description
const TEN: u8 = 10;
const ALSO_TEN: u16 = TEN;
The compiler suggests .into()
instead of an as
-cast:
error[E0308]: mismatched types
--> src/main.rs:2:23
|
2 | const ALSO_TEN: u16 = TEN;
| ^^^ expected u16, found u8
help: you can cast an `u8` to `u16`, which will zero-extend the source value
|
2 | const ALSO_TEN: u16 = TEN.into();
| ^^^^^^^^^^
Normally I'm all about phasing out as
, and we should somehow make .into()
callable on consts, but right now it's suggesting invalid code.