Are `T` and `[T; 1]` guaranteed to have the same memory layout?

Title says it all really.

1 Like

Yes, this is guaranteed by the existence of std::array::from_ref. Of course T must be Sized, otherwise [T; 1] is not even well-formed.


This is also explicitly documented.


That's awesome thanks all. I was sure I'd read it somewhere, but couldn't find it.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.