Tuples are guaranteed to be initialized in order. How about structs?
Doing some marshalling. So I have things like
let vector3d = Vector3d{x: getnextvalue(); y: getnextvalue(); z: getnextvalue()};
where "getnextvalue()" is reading a value from some stream and thus has side effects.
How about the nested case?
let place = Place(pos: Vector3d{x: getnextvalue(); y: getnextvalue(); z: getnextvalue()),
rot: Quaternion(x: getnextvalue(); y: getnextvalue(); z: getnextvalue(), s: getnextvalue()));
If this doesn't work, I have to generate a huge number of in-order "let foo = ..." followed by struct initializers to put the pieces together. Ugly, but do-able.
So, is this well-defined, or is it undefined behavior? And is it the order of the named fields in the intializer, or the order of the named fields in the struct, which matters? Thanks.
Reddit discussion four years ago indicated this worked but maybe could not be relied upon.