#How do you "restart" an iterator after reaching the end of the iterator?

7 messages · Page 1 of 1 (latest)

austere sparrow
#

I have the following iterator

let vertex_colors = [Color::RED, Color::GREEN, Color::BLUE].iter();

I want to cycle through the colors of this array. Is there some kind of ".next()" but instead of ending the iterator once it reaches the end, it fetches the first
entry in the iterator?

idle pine
#

?eval [1,2,3].into_iter().cycle().take(20).collect::<Vec<_>>()

lime needleBOT
#
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]```
austere sparrow
#

Ill try it in what im doing

austere sparrow