Rust Notes: Chars
Published: 13th of February 2022
A char in Rust represents a single unicode scalar value. A char is defined as a single character within single quotes eg: ('a').
rust
// Assign `东` to the `st` variable
let st = '东';
// Annotate the `char` type
let uff: char = '西';;
Char Considerations
- A char is not the same as a single str character.
- Strings DO NOT use chars internally.
- A char is always 4-bytes in length.
Links
https://www.manning.com/books/rust-in-action
https://www.udemy.com/course/ultimate-rust-crash-course/
https://doc.rust-lang.org/std/primitive.char.html