Skip to content

Instantly share code, notes, and snippets.

View spikespaz's full-sized avatar
🦀
Science is merely the scrutiny of magic.

Jacob Birkett spikespaz

🦀
Science is merely the scrutiny of magic.
View GitHub Profile
@spikespaz
spikespaz / vec_of_array.md
Created August 25, 2024 14:09 — forked from danielhenrymantilla/vec_of_array.md
Vec off arrays (or slices)

Question

how can I convert an array to a vec without cloning the values

Technically-correct answer

Make a Vec of references:

array.iter_mut().collect::<Vec<_>>();