Before we continue, let's establish some quick terminology:

  • Struct: like an "object" in JS. It can both be a data-only type. But can also work like a "class" with methods (both inherent and static).
  • Vec: like a JS "array".
  • Slice: like a "view" into a TypedArray in JS. You can't grow them, but you can create a "view of a view" (slice of a slice).
  • Traits: essentially the answer to the question: "what if a class could inherit from multiple other classes". Traits are also referred to as "mixins" in other languages. They don't allocate any data, but only provide methods and type definitions related to those methods.