rust-blog icon indicating copy to clipboard operation
rust-blog copied to clipboard

More iteration trait wisdom

Open HadrienG2 opened this issue 2 years ago • 0 comments

Here are a few extra things I wish I knew when I started messing with Rust's iteration traits, in addition to what your tour of Rust traits already contains:

  • Iterator is one of those few traits where you should really consider overloading the default implementation of some methods (size_hint, nth...), as it is suboptimal in many cases.
  • Extend is a thing and FromIterator should almost always be implemented in terms of it.

HadrienG2 avatar Sep 07 '23 07:09 HadrienG2