diff options
| author | blake2-ppc <blake2-ppc> | 2013-07-12 03:50:05 +0200 |
|---|---|---|
| committer | blake2-ppc <blake2-ppc> | 2013-07-13 04:31:13 +0200 |
| commit | e1d5d1c049608cf182ddc91c98d9700089a35600 (patch) | |
| tree | 23f3c6b7cc50fe256301ef588dcf7a6cf3ee0df0 /src/libextra/dlist.rs | |
| parent | 89a0c99dbee1c1327e8f8a8e5127127e2b3de88e (diff) | |
| download | rust-e1d5d1c049608cf182ddc91c98d9700089a35600.tar.gz rust-e1d5d1c049608cf182ddc91c98d9700089a35600.zip | |
dlist: Use DoubleEndedIterator for .consume_rev_iter()
Diffstat (limited to 'src/libextra/dlist.rs')
| -rw-r--r-- | src/libextra/dlist.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs index feafce58e6e..60850654607 100644 --- a/src/libextra/dlist.rs +++ b/src/libextra/dlist.rs @@ -72,11 +72,6 @@ pub struct ConsumeIterator<T> { priv list: DList<T> } -/// DList reverse consuming iterator -pub struct ConsumeRevIterator<T> { - priv list: DList<T> -} - /// Rawlink is a type like Option<T> but for holding a raw pointer impl<T> Rawlink<T> { /// Like Option::None for Rawlink @@ -346,8 +341,8 @@ impl<T> DList<T> { } /// Consume the list into an iterator yielding elements by value, in reverse - pub fn consume_rev_iter(self) -> ConsumeRevIterator<T> { - ConsumeRevIterator{list: self} + pub fn consume_rev_iter(self) -> InvertIterator<T, ConsumeIterator<T>> { + self.consume_iter().invert() } } @@ -494,11 +489,8 @@ impl<A> Iterator<A> for ConsumeIterator<A> { } } -impl<A> Iterator<A> for ConsumeRevIterator<A> { - fn next(&mut self) -> Option<A> { self.list.pop_back() } - fn size_hint(&self) -> (uint, Option<uint>) { - (self.list.length, Some(self.list.length)) - } +impl<A> DoubleEndedIterator<A> for ConsumeIterator<A> { + fn next_back(&mut self) -> Option<A> { self.list.pop_back() } } impl<A, T: Iterator<A>> FromIterator<A, T> for DList<A> { |
