I have a 3-element array:
let color = [0.25, 0.25, 0.25];
I'd like to turn it into a 4-element array, which would be the 3-element array plus one appended element:
let color_with_alpha = [color[0], color[1], color[2], 1.0];
I know Rust has some cool syntax sugar for a lot of things; is there something for this? Something like:
let color_with_alpha = [color, 1.0];
I've read about the concat macro but that seems to only create string slices. I would imagine there's a vector-based solution but I don't require the dynamic sizing.
push? If you need to keep the first vector, just useclone(), bind it to a variable, and then push to that. If you can't useclone, and can't consumecolor, then the odds are that this syntax sugar wouldn't work even if it was implemented. If dynamic resizing is an issue,let color_with_alpha = Vec::with_capacity(color.len() + 1);coloris an Array, not a Vector.