A cast to char
was attempted on a type other than u8
.
Erroneous code example:
0u32 as char; // error: only `u8` can be cast as `char`, not `u32`
As the error message indicates, only u8
can be cast into char
. Example:
let c = 86u8 as char; // ok! assert_eq!(c, 'V');
For more information about casts, take a look at the Type cast section in The Reference Book.