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
| Type | Size | Range |
|---|---|---|
i8 | 8-bit | signed |
i16 | 16-bit | signed |
i32 | 32-bit | signed |
i64 | 64-bit | signed |
isize | pointer | signed |
u8 | 8-bit | unsigned |
u16 | 16-bit | unsigned |
u32 | 32-bit | unsigned |
u64 | 64-bit | unsigned |
usize | pointer | unsigned |
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
| Type | Size |
|---|---|
f32 | 32-bit |
f64 | 64-bit |
Strings
Double-quoted. The type is String.
"hello"
"" // empty
"hello world" // spaces
Escape sequences:
| Escape | Meaning |
|---|---|
\n | newline |
\t | tab |
\r | carriage return |
\" | double quote |
\\ | backslash |
\0 | null 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