The layout of an "heap" (Storage) type is always identical to the layout of the corresponding "stack" type. E.g. the stack type Student is essentially identical to the heap type StudentStorage.
The design has two separate types because moving a value from/into the heap is not quite trivial: when moving a pointer-to-heap-value out, it must be wrapped in a GCRef, and the referent pinned. When moving a GCRef in, the referent must be unpinned. However I don't think the duplication of types is paying for itself.
Unifying the two types would probably lead to better destructor behavior.
The layout of an "heap" (
Storage
) type is always identical to the layout of the corresponding "stack" type. E.g. the stack typeStudent
is essentially identical to the heap typeStudentStorage
.The design has two separate types because moving a value from/into the heap is not quite trivial: when moving a pointer-to-heap-value out, it must be wrapped in a
GCRef
, and the referent pinned. When moving aGCRef
in, the referent must be unpinned. However I don't think the duplication of types is paying for itself.Unifying the two types would probably lead to better destructor behavior.