The predicate bound of Iterator::find
is P: FnMut(&Self::Item) -> bool
, and of Iterator::position
is P: FnMut(Self::Item) -> bool
. Note that in the second case there is no &
on Self::Item
. Is there a reason for this difference?
find
has to return the element, which means it can't consume any elements, which means it has to pass a borrow to the closure.
position
doesn't need to return the element, so it can consume elements, so it doesn't have to pass a borrow to the closure.