The question is in the title.
Because the size of the vector is dynamic, this is not possible. If you know the size of your vector though, then you can create an array with that same static size and copy the elements one by one using a
Thanks. I assume something like this is what you mean for a vector/array of length 1.
let mut test = Vec::new(); test.push(42); let mut result = [0; 1]; result = test.get(0).unwrap();
Thanks a lot, I’m going to try it!
That is exactly what I mean. Just make sure to do appropriate error checking for out-of-bound indices so that nothing bad happens
interesting, cool, thank you
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.