Summary

  • An array stores a fixed sized collection of values on the stack

  • You can use index syntax to access and mutate values in an array

  • A slice is a non-fixed sized collection of values, which may live anywhere in memory

  • You can borrow a slice from an array

  • A string slice is a thin wrapper around a byte slice which guarantees valid UTF-8 data

  • A Vec is a heap-allocated collection of values that can have dynamic size

  • Vecs take a type parameter to indicate which type they contain

  • A String is a thin wrapper around a Vec<u8>

  • You can slice up a slice using slice syntax

Get hands-on with 1200+ tech skills courses.