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.

Tags

rust