So I tried implementing an iterator, and I would like to have some feedback, if I did it “right”. The code can be found here. Some background:
PlayersMap is a struct to save the player list in a game. I want to get players by their name, so the basic building block is a
HashMap<String, Player>. For sake of simplicity, a
Player contains just his name.
But in the game, the players take turns, so there is some
order, using a
Vec<String>, and a pointer “
current” to the current player.
The iterator I wrote should start at the current player and then iterate over all players in order.
I would appreciate any feedback on this approach.