i8
, i16
, i32
, i64
, i128
, isize
u8
, u16
, u32
, u64
, u128
, usize
f32
, f64
true
, false
()
Length | Signed | Unsigned |
---|---|---|
8-bit | i8 | u8 |
16-bit | i16 | u16 |
32-bit | i32 | u32 |
64-bit | i64 | u64 |
128-bit | i128 | u128 |
arch | isize | usize |
Name | Type | Example value |
---|---|---|
Array | [3; i32] | [1, 2, 3] |
Tuple | (i32, bool) | (1, true) |
A contiguous growable array type, written as Vec<T>
, short for ‘vector’.
The vec!
macro is provided for convenient initialization:
JS:
Rust:
Funtion | What it does |
---|---|
.take(n) | reduces an iterator to it’s first n elements |
.skip(n) | skips the first n elements |
.cloned() | clones each element in the iterator |
.enumerate | turns an iterator over elements t to an iterator over elements (t: T, idx: usize) |
.cycle | loops the iterator infinitely |
.rev | reverses an iterator |
Day 21:
Haskell:
Rust:
Haskell:
Rust:
Haskell:
Rust: