Something like
const X: char = '0x10FFFC';
Yes, use \u{..}
:
const X: char = '\u{10FFFC}';
Playground
One trick for this cases is play with the compiler. If you try the following code it will give you a nice hint about what to do for example:
const X: char = 0x10FFFC as char;
error: only `u8` can be cast into `char`
--> src/lib.rs:1:17
|
1 | const X: char = 0x10FFFC as char;
| ^^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{10FFFC}'`
|
= note: `#[deny(overflowing_literals)]` on by default
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With