@@ -55,32 +55,7 @@ pub trait Iterator<A> {
55
55
pub trait DoubleEndedIterator < A > : Iterator < A > {
56
56
/// Yield an element from the end of the range, returning `None` if the range is empty.
57
57
fn next_back ( & mut self ) -> Option < A > ;
58
- }
59
-
60
- /// An object implementing random access indexing by `uint`
61
- ///
62
- /// A `RandomAccessIterator` should be either infinite or a `DoubleEndedIterator`.
63
- pub trait RandomAccessIterator < A > : Iterator < A > {
64
- /// Return the number of indexable elements. At most `std::uint::max_value`
65
- /// elements are indexable, even if the iterator represents a longer range.
66
- fn indexable ( & self ) -> uint ;
67
-
68
- /// Return an element at an index
69
- fn idx ( & self , index : uint ) -> Option < A > ;
70
- }
71
-
72
- /// Iterator adaptors provided for every `DoubleEndedIterator` implementation.
73
- ///
74
- /// In the future these will be default methods instead of a utility trait.
75
- pub trait DoubleEndedIteratorUtil {
76
- /// Flip the direction of the iterator
77
- fn invert ( self ) -> Invert < Self > ;
78
- }
79
58
80
- /// Iterator adaptors provided for every `DoubleEndedIterator` implementation.
81
- ///
82
- /// In the future these will be default methods instead of a utility trait.
83
- impl < A , T : DoubleEndedIterator < A > > DoubleEndedIteratorUtil for T {
84
59
/// Flip the direction of the iterator
85
60
///
86
61
/// The inverted iterator flips the ends on an iterator that can already
@@ -94,11 +69,23 @@ impl<A, T: DoubleEndedIterator<A>> DoubleEndedIteratorUtil for T {
94
69
/// Note: Random access with inverted indices still only applies to the first
95
70
/// `uint::max_value` elements of the original iterator.
96
71
#[ inline]
97
- fn invert ( self ) -> Invert < T > {
72
+ fn invert ( self ) -> Invert < Self > {
98
73
Invert { iter : self }
99
74
}
100
75
}
101
76
77
+ /// An object implementing random access indexing by `uint`
78
+ ///
79
+ /// A `RandomAccessIterator` should be either infinite or a `DoubleEndedIterator`.
80
+ pub trait RandomAccessIterator < A > : Iterator < A > {
81
+ /// Return the number of indexable elements. At most `std::uint::max_value`
82
+ /// elements are indexable, even if the iterator represents a longer range.
83
+ fn indexable ( & self ) -> uint ;
84
+
85
+ /// Return an element at an index
86
+ fn idx ( & self , index : uint ) -> Option < A > ;
87
+ }
88
+
102
89
/// An double-ended iterator with the direction inverted
103
90
#[ deriving( Clone ) ]
104
91
pub struct Invert < T > {
0 commit comments