Tutorial by Examples

An array is a stack-allocated, statically-sized list of objects of a single type. Arrays are usually created by enclosing a list of elements of a given type between square brackets. The type of an array is denoted with the special syntax: [T; N] where T is the type of its elements and N their count...
A vector is essentially a pointer to a heap-allocated, dynamically-sized list of objects of a single type. Example fn main() { // Create a mutable empty vector let mut vector = Vec::new(); vector.push(20); vector.insert(0, 10); // insert at the beginning println!(&qu...
Slices are views into a list of objects, and have type [T], indicating a slice of objects with type T. A slice is an unsized type, and therefore can only be used behind a pointer. (String world analogy: str, called string slice, is also unsized.) Arrays get coerced into slices, and vectors can be...

Page 1 of 1