It is useful for functions to accept a dyn IntoIterator<blah> object, which allows you to use into_iter(), but that requires taking ownership of the collection.
It seems like Rust lacks a trait for the iter() method. Does something like the itertools crate provide a replacement?
Is there an trait for a resettable/restartable iterator?
Is there some alternative for a function that:
- Wants to iterate over a collection several times without cloning it.
- Does not want to take ownership of anything.
I guess I could take Iterator<Item=T>+Clone, but that's a bit ugly (I'd have to use the iterator before using it the first time).
I should add my actual goal: I would like to make a bunch of functions that can take both &[T] or &IndexSet<T> (from indexmap crate) as arguments.