Primitive Data Types in Detail
Primitive Data Types in Detail
Rust is statically and strongly typed with full type inference.
Scalar Types
- Integers:
- Signed:
i8,i16,i32,i64,i128,isize(pointer width) - Unsigned:
u8,u16,u32,u64,u128,usize(pointer width, indexing)
- Signed:
- Floating-point:
f32,f64(IEEE 754-2008) - Boolean:
bool(trueorfalse, 1 byte representation) - Character:
char(4-byte Unicode scalar value)
fn main() {
let count: usize = 42;
let temperature: f64 = 98.6;
let is_active: bool = true;
let emoji: char = '🦀';
println!("Scalar values: {}, {}, {}, {}", count, temperature, is_active, emoji);
}