Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Literals & Primitive Types

Integers

Integer literals default to i64. Underscores can be used as visual separators.

42
0
9999999
1_000_000

Alternate bases:

0xff          // hexadecimal (case-insensitive: 0XAB, 0xDeAdBeEf)
0b1010        // binary (0B1100)
0o77          // octal (0O55)

Integer Types

TypeSizeRange
i88-bitsigned
i1616-bitsigned
i3232-bitsigned
i6464-bitsigned
isizepointersigned
u88-bitunsigned
u1616-bitunsigned
u3232-bitunsigned
u6464-bitunsigned
usizepointerunsigned

Floats

Float literals default to f64. Underscores allowed.

3.14159
0.5
100.0
1_000.5

Scientific notation:

1e10          // 10000000000.0
1.5e10        // 15000000000.0
2.5e-3        // 0.0025
3.0e+7        // 30000000.0

Float Types

TypeSize
f3232-bit
f6464-bit

Strings

Double-quoted. The type is String.

"hello"
""                    // empty
"hello world"         // spaces

Escape sequences:

EscapeMeaning
\nnewline
\ttab
\rcarriage return
\"double quote
\\backslash
\0null byte
\'single quote

Triple-quoted strings for raw content:

"""triple quoted"""

Booleans

true
false

The type is bool.

Bytes

Single-quoted character literals produce a u8 value:

'a'           // 97
'z'
'0'
' '           // space

Escape sequences work in byte literals too:

'\n'          // newline byte
'\t'          // tab byte
'\\'          // backslash byte
'\''          // single quote byte
'\0'          // null byte