Thanks - great to see different options for how to do it!
Can you think of a way to use the helper function and somehow infer the size of the struct member so it doesn't have to be repeated? Not a huge deal but I can't figure out how to do it.
I don't know how to do that exactly. The closest I could come up with would be to leave the array undefined and use a helper function to fill it in, but that has slightly different semantics since the memcpy is a little more explicit:
Thanks - great to see different options for how to do it!
Can you think of a way to use the helper function and somehow infer the size of the struct member so it doesn't have to be repeated? Not a huge deal but I can't figure out how to do it.
I don't know how to do that exactly. The closest I could come up with would be to leave the array
undefined
and use a helper function to fill it in, but that has slightly different semantics since thememcpy
is a little more explicit:Good solution. I haven't seen std.meta.Elem before so I'm going to go read up on that. Thanks!