Stdlib: StaticTuple vs InlineArray

I’m trying to make a small, fixed-sized matrix struct. In order to do it, I need some fixed-sized stack-allocated buffer for values of a given type. In the standard library I found StaticArray and InlineArray that look like good candidates, but I’m not sure what their fundamental differences are. Two of the most significant differences (for me) are:

  • StaticArray is register passable while InlineArray is not (since InlineArray only requires the elements to satisfy the CollectionElement trait).
  • InlineArray allows you to get a pointer to the buffer, but StaticTuple does not.

Is there a rule of thumb about when someone should use one over the other? And are these types meant to serve two distinct purposes?

You probably want InlineArray, but due to type system issues we can’t make a 2d array of InlineArray. As a result, you may need to build your own, either on top of the unstable !pop.array, or using a raw pointer. You aren’t the first person to run into this limitation and it should get resolved eventually.