First, let's clarify this last point in your question:
For example, (1..10) can implement this in order to be able to go from 1 to 10 or from 10 to 1.
1..10 is of type std::ops::Range<T> and iterates in the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9 regardless if you repeat it from the back or front. From the back you get 9, 8, ..., from the front you get, 1, 2, ...; this is the start, end exclusive range, also called the half - open range.
If you go over the range a little in front, and then from the back, it will stop where the ends end:
let mut range = 1..10; for i in &mut range { // Produce 1, 2, 3, 4, 5 // then break. if i == 5 { break; } } for j in range.rev() { // Produces 9, 8, 7, 6 }
And this shows how the double-ended iterator works well. (link to rust backpack)
Now, when it comes to DoubleEndedIterator "abuse":
This is problematic.
The documentation for DoubleEndedIterator is clear:
Range iterator capable of outputting elements from both ends
A DoubleEndedIterator can be thought of as a deque in that next() and next_back() exhaust elements from the same range, and do not work independently of each other.
You should understand this as: regardless of whether you use next , next_back or their combinations, any traversal should give the same range of elements if you track them (and keep track of where they came from).
However, there is a case of infinite ranges ...
In an infinitely long range, ends never meet. An example of such an iterator is repeat . For this trivial example, it is easy to understand why the iterator is infinite, and both next() and next_back() are logically defined.
So, this is a loophole where you can specify the iterator sequence as infinitely long, albeit double. I think it is doubtful to try to correctly execute this interface with our fixed width integers.
Even with dubious philosophical motivation, it can be a very confusing iterator that defies reasonable expectations. I think it would be terribly wrong to use the trait (for example, to have two completely dissenting ends of the iterator), but with an inexhaustible range, you actually do not violate any property properties.