]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0604.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0604.md
1 A cast to `char` was attempted on a type other than `u8`.
2
3 Erroneous code example:
4
5 ```compile_fail,E0604
6 0u32 as char; // error: only `u8` can be cast as `char`, not `u32`
7 ```
8
9 As the error message indicates, only `u8` can be cast into `char`. Example:
10
11 ```
12 let c = 86u8 as char; // ok!
13 assert_eq!(c, 'V');
14 ```
15
16 For more information about casts, take a look at the Type cast section in
17 [The Reference Book][1].
18
19 [1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions