Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

In Rust, the character type (char) represents a unicode character.

Literal values are written using single quotes ('):

('A', 'ô', '∉')

Some special characters (see Table 1) are inserted using the escape character (backslash):

('\t', '\n')

The escape character is also used to insert ASCII, 8-bit or Unicode characters knowing their number:

('9', '∈')

The from() method permits to convert an integer into a character:

'0'

Table 1:Character escapes

Escape

Number

Name

Description

\0

0x00

NL, NUL or NULL

Null

\t

0x09

HT

Tab

\n

0x0A

LF

Newline (a.k.a.: line feed)

\r

0x0D

CR

Carriage return

\\

0x5C

Backslash

\'

0x27

Single quote

\"

0x22

Double quote

\x41, \x7f, ...

ASCII or 8-bit character code

\u{7fff}

24-bit Unicode character code (up to 6 hex digits)