#E0053: invalid cast
as converts between numbers, bool and char, and a payload-less enum to an integer; other conversions are methods. Only u8 casts to char (use char::from_u32(n) for wider values), and nothing casts to bool (compare: n != 0). Use the conversion method the message suggests.
nabi
let n = 98u32;
let c = n as char;
error[E0053]: only `u8` can be cast as `char`, not `u32`; use `char::from_u32(n)` (`char | none`) for a wider value --> main.nabi:2:9 | 2 | let c = n as char; | ^^^^^^^^^
Convert with char::from_u32, which gives none for values that are not characters:
nabi
let n = 98u32;
let c = char::from_u32(n) ?? '?';
println(f"{c}");
b
Related: E0040 mismatched types
Found a mistake? Edit this page on GitHub. Last updated