Skip to content

Commit de14466

Browse files
author
Jorge Aparicio
committed
core: merge DoubleEndedIteratorExt into IteratorExt
1 parent 6c0ad5b commit de14466

File tree

11 files changed

+29
-37
lines changed

11 files changed

+29
-37
lines changed

src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mod prelude {
110110
pub use core::iter::range;
111111
pub use core::iter::{FromIterator, Extend, IteratorExt};
112112
pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
113-
pub use core::iter::{IteratorCloneExt, CloneIteratorExt, DoubleEndedIteratorExt};
113+
pub use core::iter::{IteratorCloneExt, CloneIteratorExt};
114114
pub use core::iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
115115
pub use core::kinds::{Copy, Send, Sized, Sync};
116116
pub use core::mem::drop;

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ pub mod raw {
14491449
mod tests {
14501450
use std::boxed::Box;
14511451
use prelude::{Some, None, range, Vec, ToString, Clone, Greater, Less, Equal};
1452-
use prelude::{SliceExt, Iterator, IteratorExt, DoubleEndedIteratorExt};
1452+
use prelude::{SliceExt, Iterator, IteratorExt};
14531453
use prelude::AsSlice;
14541454
use prelude::{RandomAccessIterator, Ord, SliceConcatExt};
14551455
use core::cell::Cell;

src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,7 @@ mod tests {
32783278
#[cfg(test)]
32793279
mod bench {
32803280
use super::*;
3281-
use prelude::{SliceExt, IteratorExt, DoubleEndedIteratorExt, SliceConcatExt};
3281+
use prelude::{SliceExt, IteratorExt, SliceConcatExt};
32823282
use test::Bencher;
32833283
use test::black_box;
32843284

src/libcore/fmt/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use self::SignFormat::*;
1717
use char;
1818
use char::Char;
1919
use fmt;
20-
use iter::{range, DoubleEndedIteratorExt};
20+
use iter::{IteratorExt, range};
2121
use num::{cast, Float, ToPrimitive};
2222
use num::FpCategory as Fp;
2323
use ops::FnOnce;

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![allow(unsigned_negation)]
1616

1717
use fmt;
18-
use iter::DoubleEndedIteratorExt;
18+
use iter::IteratorExt;
1919
use num::{Int, cast};
2020
use slice::SliceExt;
2121
use str;

src/libcore/iter.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,24 @@ pub trait IteratorExt: Iterator + Sized {
719719
}
720720
}).map(|(x, _)| x)
721721
}
722+
723+
/// Change the direction of the iterator
724+
///
725+
/// The flipped iterator swaps the ends on an iterator that can already
726+
/// be iterated from the front and from the back.
727+
///
728+
///
729+
/// If the iterator also implements RandomAccessIterator, the flipped
730+
/// iterator is also random access, with the indices starting at the back
731+
/// of the original iterator.
732+
///
733+
/// Note: Random access with flipped indices still only applies to the first
734+
/// `uint::MAX` elements of the original iterator.
735+
#[inline]
736+
#[stable]
737+
fn rev(self) -> Rev<Self> {
738+
Rev{iter: self}
739+
}
722740
}
723741

724742
#[unstable = "trait is unstable"]
@@ -772,31 +790,6 @@ pub trait DoubleEndedIterator: Iterator {
772790
fn next_back(&mut self) -> Option< <Self as Iterator>::Item>;
773791
}
774792

775-
/// Extension methods for double-ended iterators.
776-
#[unstable = "new extension trait convention"]
777-
pub trait DoubleEndedIteratorExt: DoubleEndedIterator + Sized {
778-
/// Change the direction of the iterator
779-
///
780-
/// The flipped iterator swaps the ends on an iterator that can already
781-
/// be iterated from the front and from the back.
782-
///
783-
///
784-
/// If the iterator also implements RandomAccessIterator, the flipped
785-
/// iterator is also random access, with the indices starting at the back
786-
/// of the original iterator.
787-
///
788-
/// Note: Random access with flipped indices still only applies to the first
789-
/// `uint::MAX` elements of the original iterator.
790-
#[inline]
791-
#[stable]
792-
fn rev(self) -> Rev<Self> {
793-
Rev{iter: self}
794-
}
795-
}
796-
797-
#[unstable = "trait is unstable"]
798-
impl<I> DoubleEndedIteratorExt for I where I: DoubleEndedIterator {}
799-
800793
/// A double-ended iterator yielding mutable references
801794
#[experimental = "not widely used"]
802795
pub trait MutableDoubleEndedIterator {

src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub use char::Char;
4242
pub use clone::Clone;
4343
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
4444
pub use iter::{Extend, IteratorExt};
45-
pub use iter::{Iterator, DoubleEndedIterator, DoubleEndedIteratorExt};
45+
pub use iter::{Iterator, DoubleEndedIterator};
4646
pub use iter::{IteratorCloneExt, CloneIteratorExt};
4747
pub use iter::{IteratorOrdExt, ExactSizeIterator, IteratorPairExt};
4848
pub use option::Option::{mod, Some, None};

src/libcore/str/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use self::Searcher::{Naive, TwoWay, TwoWayLong};
2121
use cmp::{mod, Eq};
2222
use default::Default;
2323
use iter::range;
24-
use iter::{DoubleEndedIteratorExt, ExactSizeIterator};
24+
use iter::ExactSizeIterator;
2525
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
2626
use kinds::Sized;
2727
use mem;

src/libstd/path/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use clone::Clone;
1515
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
1616
use hash;
1717
use io::Writer;
18-
use iter::{DoubleEndedIteratorExt, AdditiveIterator, Extend};
18+
use iter::{AdditiveIterator, Extend};
1919
use iter::{Iterator, IteratorExt, Map};
2020
use option::Option;
2121
use option::Option::{None, Some};
@@ -449,7 +449,7 @@ mod tests {
449449
use super::*;
450450

451451
use clone::Clone;
452-
use iter::{IteratorExt, DoubleEndedIteratorExt};
452+
use iter::IteratorExt;
453453
use option::Option::{mod, Some, None};
454454
use path::GenericPath;
455455
use slice::{AsSlice, SliceExt};

src/libstd/path/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use clone::Clone;
2020
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
2121
use hash;
2222
use io::Writer;
23-
use iter::{AdditiveIterator, DoubleEndedIteratorExt, Extend};
23+
use iter::{AdditiveIterator, Extend};
2424
use iter::{Iterator, IteratorExt, Map, repeat};
2525
use mem;
2626
use option::Option;
@@ -1124,7 +1124,7 @@ mod tests {
11241124
use super::*;
11251125

11261126
use clone::Clone;
1127-
use iter::{IteratorExt, DoubleEndedIteratorExt};
1127+
use iter::IteratorExt;
11281128
use option::Option::{mod, Some, None};
11291129
use path::GenericPath;
11301130
use slice::{AsSlice, SliceExt};

src/libstd/prelude/v1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#[stable] #[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
2828
#[stable] #[doc(no_inline)] pub use iter::CloneIteratorExt;
2929
#[stable] #[doc(no_inline)] pub use iter::DoubleEndedIterator;
30-
#[stable] #[doc(no_inline)] pub use iter::DoubleEndedIteratorExt;
3130
#[stable] #[doc(no_inline)] pub use iter::ExactSizeIterator;
3231
#[stable] #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
3332
#[stable] #[doc(no_inline)] pub use iter::{IteratorCloneExt, IteratorOrdExt};

0 commit comments

Comments
 (0)