SYS.REF / 001 / RUST

RUST DATA TYPES:
A VISUAL REFERENCE.

CORE TYPES07QUICK GUIDE
01

TEXT TYPES

UTF-8 encoded string data

&strTYPE::&STR

STRING SLICE

A borrowed view into valid UTF-8 text.

let greeting: &str =
    "Hello, Rust!";
StringTYPE::STRING

OWNED STRING

Growable, owned UTF-8 text stored on the heap.

let mut name =
    String::from("Alice");
02

INTEGER TYPES

Whole-number scalar values

i32TYPE::I32

SIGNED INTEGER

A 32-bit whole number that supports negative values.

let count: i32 = -100;
u64TYPE::U64

UNSIGNED INTEGER

A 64-bit whole number whose minimum value is zero.

let id: u64 = 1048576;
03

OTHER COMMON TYPES

Logic, precision & characters

boolTYPE::BOOL

BOOLEAN

A logical value that is either true or false.

let is_active: bool = true;
f64TYPE::F64

FLOAT

A double-precision IEEE 754 floating-point number.

let pi: f64 = 3.14159;
charTYPE::CHAR

UNICODE CHAR

One Unicode scalar value stored in four bytes.

let initial: char = 'R';

NOTE Rust is statically typed, so every value has one known type at compile time.

API: /api/rust-types