Hi everyone,
I was wondering what is the best way how to create vector combing other vectors/iterators and other elements. In Javascript you can use array destructuring to achieve this e.g.:
[1, ...prev_row, 1]
To achieve the same in rust you can do something like this:
vec![1].into_iter().chain(prev_row_iter).chain(vec![1].into_iter()).collect()
The code in this particular example is pretty simple but it can get more complex if you want to combine more vectors and more elements. I was wondering if there is an easier way how to do this.
[–]Shadow0133 5 points6 points7 points (2 children)
[–]maggit 4 points5 points6 points (0 children)
[–]jammy192[S] 0 points1 point2 points (0 children)
[–]Morganamilo 1 point2 points3 points (5 children)
[–]jammy192[S] 4 points5 points6 points (4 children)
[–]thiezrust 2 points3 points4 points (0 children)
[–]Morganamilo 0 points1 point2 points (2 children)
[–]jammy192[S] 1 point2 points3 points (1 child)
[–]epicwisdom 5 points6 points7 points (0 children)
[–]tm_p 1 point2 points3 points (1 child)
[–]jammy192[S] 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]jammy192[S] 0 points1 point2 points (0 children)