I want a const, but need a var first, to initialize. I think a good way to do it would be as in this contrivance:
const c = init: {
var c_ = [_]u8{1, 2, 3};
c_[1] = 5;
break :init c_;
};
-
True?
-
I think this may result in an item-by-item copy from c_ to the final c; yes/no?
-
If yes, is there a different way… a way to simply tell the compiler, “I just want a symbol that references the modified array, and want it to be considered const from here on out”?
-
If no, is this construct susceptible to the “aliasing” problems that I remember half-internalizing when discussed a couple of months ago? I feel like it wouldn’t even matter, in this case, though, since I’ve got a const in the end.
-
Extra: is there a quick way to school me in discovering the answer to number 2, by myself, via godbolt or something? Keep in mind that I’m not very assembly-savvy, and the answer may therefore be: “yeah, if you were more assembly-savvy, but skip it for now.”