No description
Find a file
Eryn Wells fb6fd27453 [board] Remove Iterator implementations form move generator types; replace it with an iter() method
I was given some guidance[1] on the Rust developer forums that my approach of
implementing Iterator on these types wasn't quite right.

> In general, iterators are distinct data structures than the primary struct
that owns the data, in part due to issues like this, but also due to concerns
around iterator invalidation and the need to carry around iteration state more
generally.

I took this to heart and replace the Iterator implementations with an iter()
method that returns an `impl Iterator<Item=Move>`. This works so much better and
lets me delete a bunch of code!

Additionally, the iter() methods on the piece-wise move generator types return
`impl Iterator<Item=&Move>`, and then the top-level Moves::iter() returns a
.cloned().

Overall I'm really happy with this!

[1]: https://users.rust-lang.org/t/tricky-lifetime-may-not-live-long-enough-error-on-an-iterator-wrapping-a-boxed-iterator/104650/3
2024-01-01 09:33:37 -08:00
board [board] Remove Iterator implementations form move generator types; replace it with an iter() method 2024-01-01 09:33:37 -08:00
explorer [explorer] A REPL-style command line app to fiddle with chess boards 2023-12-28 15:09:15 -07:00
.gitignore Ignore the target/ directory 2023-12-19 11:13:41 -08:00
Notes.md Add some notes 2023-12-22 08:51:18 -08:00