2025-03-13 21:20:56 +01:00

801 B

name = "Vecs and slices" difficulty = 2 exercises = ["access.md"]
name = "Vecs and slices" difficulty = 2 exercises = ["access.md"]

Let's now look at some functions on slices and Vecs. Instead of manualy checking things we will follow the type system using Options and Results we saw earlier.

note

Slices ([T]) represent some memory space containing an arbitrary number of elements of type T. Since they don't have a size known at compilation time, we can only access them through pointers, commonly &[T] (references to slices).

deepening

Vec<T> can be seen as owned [T], it means that every function working on a &[T] can work on a &Vec<T>.