Course lesson
Char Type in Rust
This lesson discusses the char type in Rust, which holds 32 bit unicode values.
- Duration
- 1 min
- Access
- Free
- Transcript
- Available
This lesson discusses the char type in Rust, which holds 32 bit unicode values.
Course lesson
This lesson discusses the char type in Rust, which holds 32 bit unicode values.
This lesson discusses the char type in Rust, which holds 32 bit unicode values.
Instructor: A character type or a char is a single Unicode character as a 32-bit value. They're created using single quotes. Here we see a couple of examples. Char1 is a character, '1'. Char2 is a character, 'a'. We can use any character Unicode that we like. Even emojis work, as we can see here.
Some characters have special meanings, so they need to be escaped using a . Here we see a \ escaping a , or a \ escaping a single quote. The same goes for a new line, a carriage return, and so on and so forth.
To see that this is working, we can, for example, create a new command here and say println!("{:?}" , "some more text"). Then we can give it, for example, char4 and run the program. We'll see, it'll output a backslash plus some text.
Course lesson
This lesson discusses the char type in Rust, which holds 32 bit unicode values.