I just read the docs of Rev for unrelated reasons.
I wonder why rev() is defined on Iterator?
It requires Self: DoubleEndedIterator, so why isn't it defined there? After all, DoubleEndedIterator is a subtrait of Iterator.
I believe that's just historical baggage, which we can't change since 1.0 because it would be a breaking change. The rposition method is similarly weird, and this was debated a bit when rfind was added, ultimately on DoubleEndedIterator in spite of the PR title:
I suspected as much, but both were introduced in 1.0 according to the docs, so I thought that this was a deliberate design decision that I just didn't understand.
A couple of minor advantages (even if unintentional) that come to mind:
- Much better discoverability in the docs
- No need for an extra import to bring the method to scope.
DoubleEndedIterator is in the prelude.
Don't forget that “introduced in 1.0” means “introduced in nine years between 2006 and 2015”. It's not like “introduced in 1.x” for any other x
Thanks, should've double-checked.
I wonder. Would Evolving trait hierarhies allow to "fix" this. That is move rev method definition from Iterator to DobuleEndedIterator?
I think not, the supertrait relationship is backwards for that proposal.