Remove IteratorExt
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
This commit is contained in:
parent
3e7385aae9
commit
d502f4221f
@ -951,7 +951,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::clone::Clone;
|
||||
use std::iter::{Iterator, IteratorExt};
|
||||
use std::iter::Iterator;
|
||||
use std::option::Option::{Some, None, self};
|
||||
use std::rand;
|
||||
use std::thread;
|
||||
|
@ -76,7 +76,6 @@
|
||||
//! iterators.
|
||||
//! * Further methods that return iterators are `.split()`, `.splitn()`,
|
||||
//! `.chunks()`, `.windows()` and more.
|
||||
|
||||
#![doc(primitive = "slice")]
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
@ -85,7 +84,7 @@
|
||||
use core::clone::Clone;
|
||||
use core::cmp::Ordering::{self, Greater, Less};
|
||||
use core::cmp::{self, Ord, PartialEq};
|
||||
use core::iter::{Iterator, IteratorExt};
|
||||
use core::iter::Iterator;
|
||||
use core::iter::MultiplicativeIterator;
|
||||
use core::marker::Sized;
|
||||
use core::mem::size_of;
|
||||
@ -131,7 +130,7 @@ mod hack {
|
||||
use alloc::boxed::Box;
|
||||
use core::clone::Clone;
|
||||
#[cfg(test)]
|
||||
use core::iter::{Iterator, IteratorExt};
|
||||
use core::iter::Iterator;
|
||||
use core::mem;
|
||||
#[cfg(test)]
|
||||
use core::option::Option::{Some, None};
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
use core::clone::Clone;
|
||||
use core::iter::AdditiveIterator;
|
||||
use core::iter::{Iterator, IteratorExt, Extend};
|
||||
use core::iter::{Iterator, Extend};
|
||||
use core::option::Option::{self, Some, None};
|
||||
use core::result::Result;
|
||||
use core::str as core_str;
|
||||
|
@ -1785,7 +1785,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use core::iter::{IteratorExt, self};
|
||||
use core::iter::{Iterator, self};
|
||||
use core::option::Option::Some;
|
||||
|
||||
use test;
|
||||
|
@ -66,7 +66,7 @@ macro_rules! map_find_rand_bench {
|
||||
($name: ident, $n: expr, $map: ident) => (
|
||||
#[bench]
|
||||
pub fn $name(b: &mut ::test::Bencher) {
|
||||
use std::iter::IteratorExt;
|
||||
use std::iter::Iterator;
|
||||
use std::rand::Rng;
|
||||
use std::rand;
|
||||
use std::vec::Vec;
|
||||
|
@ -17,7 +17,7 @@
|
||||
use char;
|
||||
use char::CharExt;
|
||||
use fmt;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use num::{cast, Float, ToPrimitive};
|
||||
use num::FpCategory as Fp;
|
||||
use ops::FnOnce;
|
||||
|
@ -15,7 +15,7 @@
|
||||
use any;
|
||||
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
|
||||
use char::CharExt;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use iter::Iterator;
|
||||
use marker::{Copy, PhantomData, Sized};
|
||||
use mem;
|
||||
use option::Option;
|
||||
|
@ -15,7 +15,7 @@
|
||||
#![allow(unsigned_negation)]
|
||||
|
||||
use fmt;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use num::{Int, cast};
|
||||
use slice::SliceExt;
|
||||
use str;
|
||||
|
@ -71,6 +71,8 @@
|
||||
use marker::Sized;
|
||||
use usize;
|
||||
|
||||
fn _assert_is_object_safe(_: &Iterator) {}
|
||||
|
||||
/// An interface for dealing with "external iterators". These types of iterators
|
||||
/// can be resumed at any time as all state is stored internally as opposed to
|
||||
/// being located on the call stack.
|
||||
@ -101,62 +103,7 @@ pub trait Iterator {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) { (0, None) }
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
|
||||
type Item = I::Item;
|
||||
fn next(&mut self) -> Option<I::Item> { (**self).next() }
|
||||
fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
|
||||
}
|
||||
|
||||
/// Conversion from an `Iterator`
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
|
||||
built from an iterator over elements of type `{A}`"]
|
||||
pub trait FromIterator<A> {
|
||||
/// Build a container with elements from something iterable.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn from_iter<T: IntoIterator<Item=A>>(iterator: T) -> Self;
|
||||
}
|
||||
|
||||
/// Conversion into an `Iterator`
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait IntoIterator {
|
||||
/// The type of the elements being iterated
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
type Item;
|
||||
|
||||
/// A container for iterating over elements of type Item
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
type IntoIter: Iterator<Item=Self::Item>;
|
||||
|
||||
/// Consumes `Self` and returns an iterator over it
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn into_iter(self) -> Self::IntoIter;
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator> IntoIterator for I {
|
||||
type Item = I::Item;
|
||||
type IntoIter = I;
|
||||
|
||||
fn into_iter(self) -> I {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A type growable from an `Iterator` implementation
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait Extend<A> {
|
||||
/// Extend a container with the elements yielded by an arbitrary iterator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn extend<T: IntoIterator<Item=A>>(&mut self, iterable: T);
|
||||
}
|
||||
|
||||
/// An extension trait providing numerous methods applicable to all iterators.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait IteratorExt: Iterator + Sized {
|
||||
/// Counts the number of elements in this iterator.
|
||||
///
|
||||
/// # Examples
|
||||
@ -167,7 +114,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn count(self) -> usize {
|
||||
fn count(self) -> usize where Self: Sized {
|
||||
self.fold(0, |cnt, _x| cnt + 1)
|
||||
}
|
||||
|
||||
@ -181,7 +128,7 @@ fn count(self) -> usize {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn last(self) -> Option<Self::Item> {
|
||||
fn last(self) -> Option<Self::Item> where Self: Sized {
|
||||
let mut last = None;
|
||||
for x in self { last = Some(x); }
|
||||
last
|
||||
@ -200,7 +147,7 @@ fn last(self) -> Option<Self::Item> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
|
||||
fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized {
|
||||
for x in self.by_ref() {
|
||||
if n == 0 { return Some(x) }
|
||||
n -= 1;
|
||||
@ -225,7 +172,7 @@ fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn chain<U>(self, other: U) -> Chain<Self, U> where
|
||||
U: Iterator<Item=Self::Item>,
|
||||
Self: Sized, U: Iterator<Item=Self::Item>,
|
||||
{
|
||||
Chain{a: self, b: other, flag: false}
|
||||
}
|
||||
@ -260,7 +207,7 @@ fn chain<U>(self, other: U) -> Chain<Self, U> where
|
||||
/// both produce the same output.
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
|
||||
fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> where Self: Sized {
|
||||
Zip{a: self, b: other}
|
||||
}
|
||||
|
||||
@ -279,7 +226,7 @@ fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn map<B, F>(self, f: F) -> Map<Self, F> where
|
||||
F: FnMut(Self::Item) -> B,
|
||||
Self: Sized, F: FnMut(Self::Item) -> B,
|
||||
{
|
||||
Map{iter: self, f: f}
|
||||
}
|
||||
@ -299,7 +246,7 @@ fn map<B, F>(self, f: F) -> Map<Self, F> where
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
|
||||
P: FnMut(&Self::Item) -> bool,
|
||||
Self: Sized, P: FnMut(&Self::Item) -> bool,
|
||||
{
|
||||
Filter{iter: self, predicate: predicate}
|
||||
}
|
||||
@ -319,7 +266,7 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
|
||||
F: FnMut(Self::Item) -> Option<B>,
|
||||
Self: Sized, F: FnMut(Self::Item) -> Option<B>,
|
||||
{
|
||||
FilterMap { iter: self, f: f }
|
||||
}
|
||||
@ -341,7 +288,7 @@ fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn enumerate(self) -> Enumerate<Self> {
|
||||
fn enumerate(self) -> Enumerate<Self> where Self: Sized {
|
||||
Enumerate{iter: self, count: 0}
|
||||
}
|
||||
|
||||
@ -365,7 +312,7 @@ fn enumerate(self) -> Enumerate<Self> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn peekable(self) -> Peekable<Self> {
|
||||
fn peekable(self) -> Peekable<Self> where Self: Sized {
|
||||
Peekable{iter: self, peeked: None}
|
||||
}
|
||||
|
||||
@ -386,7 +333,7 @@ fn peekable(self) -> Peekable<Self> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
|
||||
P: FnMut(&Self::Item) -> bool,
|
||||
Self: Sized, P: FnMut(&Self::Item) -> bool,
|
||||
{
|
||||
SkipWhile{iter: self, flag: false, predicate: predicate}
|
||||
}
|
||||
@ -407,7 +354,7 @@ fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
|
||||
P: FnMut(&Self::Item) -> bool,
|
||||
Self: Sized, P: FnMut(&Self::Item) -> bool,
|
||||
{
|
||||
TakeWhile{iter: self, flag: false, predicate: predicate}
|
||||
}
|
||||
@ -426,7 +373,7 @@ fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn skip(self, n: usize) -> Skip<Self> {
|
||||
fn skip(self, n: usize) -> Skip<Self> where Self: Sized {
|
||||
Skip{iter: self, n: n}
|
||||
}
|
||||
|
||||
@ -445,7 +392,7 @@ fn skip(self, n: usize) -> Skip<Self> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn take(self, n: usize) -> Take<Self> {
|
||||
fn take(self, n: usize) -> Take<Self> where Self: Sized, {
|
||||
Take{iter: self, n: n}
|
||||
}
|
||||
|
||||
@ -472,7 +419,7 @@ fn take(self, n: usize) -> Take<Self> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
|
||||
where F: FnMut(&mut St, Self::Item) -> Option<B>,
|
||||
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
|
||||
{
|
||||
Scan{iter: self, f: f, state: initial_state}
|
||||
}
|
||||
@ -495,7 +442,7 @@ fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
|
||||
where U: Iterator, F: FnMut(Self::Item) -> U,
|
||||
where Self: Sized, U: Iterator, F: FnMut(Self::Item) -> U,
|
||||
{
|
||||
FlatMap{iter: self, f: f, frontiter: None, backiter: None }
|
||||
}
|
||||
@ -529,7 +476,7 @@ fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn fuse(self) -> Fuse<Self> {
|
||||
fn fuse(self) -> Fuse<Self> where Self: Sized {
|
||||
Fuse{iter: self, done: false}
|
||||
}
|
||||
|
||||
@ -555,7 +502,7 @@ fn fuse(self) -> Fuse<Self> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
|
||||
F: FnMut(&Self::Item),
|
||||
Self: Sized, F: FnMut(&Self::Item),
|
||||
{
|
||||
Inspect{iter: self, f: f}
|
||||
}
|
||||
@ -575,7 +522,7 @@ fn inspect<F>(self, f: F) -> Inspect<Self, F> where
|
||||
/// assert!(it.next() == Some(5));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn by_ref(&mut self) -> &mut Self { self }
|
||||
fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
|
||||
|
||||
/// Loops through the entire iterator, collecting all of the elements into
|
||||
/// a container implementing `FromIterator`.
|
||||
@ -590,7 +537,7 @@ fn by_ref(&mut self) -> &mut Self { self }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn collect<B: FromIterator<Self::Item>>(self) -> B {
|
||||
fn collect<B: FromIterator<Self::Item>>(self) -> B where Self: Sized {
|
||||
FromIterator::from_iter(self)
|
||||
}
|
||||
|
||||
@ -609,6 +556,7 @@ fn collect<B: FromIterator<Self::Item>>(self) -> B {
|
||||
#[unstable(feature = "core",
|
||||
reason = "recently added as part of collections reform")]
|
||||
fn partition<B, F>(self, mut f: F) -> (B, B) where
|
||||
Self: Sized,
|
||||
B: Default + Extend<Self::Item>,
|
||||
F: FnMut(&Self::Item) -> bool
|
||||
{
|
||||
@ -638,7 +586,7 @@ fn partition<B, F>(self, mut f: F) -> (B, B) where
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn fold<B, F>(self, init: B, mut f: F) -> B where
|
||||
F: FnMut(B, Self::Item) -> B,
|
||||
Self: Sized, F: FnMut(B, Self::Item) -> B,
|
||||
{
|
||||
let mut accum = init;
|
||||
for x in self {
|
||||
@ -658,7 +606,9 @@ fn fold<B, F>(self, init: B, mut f: F) -> B where
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
|
||||
fn all<F>(&mut self, mut f: F) -> bool where
|
||||
Self: Sized, F: FnMut(Self::Item) -> bool
|
||||
{
|
||||
for x in self.by_ref() { if !f(x) { return false; } }
|
||||
true
|
||||
}
|
||||
@ -679,7 +629,10 @@ fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
|
||||
fn any<F>(&mut self, mut f: F) -> bool where
|
||||
Self: Sized,
|
||||
F: FnMut(Self::Item) -> bool
|
||||
{
|
||||
for x in self.by_ref() { if f(x) { return true; } }
|
||||
false
|
||||
}
|
||||
@ -699,6 +652,7 @@ fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
|
||||
Self: Sized,
|
||||
P: FnMut(&Self::Item) -> bool,
|
||||
{
|
||||
for x in self.by_ref() {
|
||||
@ -722,6 +676,7 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
|
||||
Self: Sized,
|
||||
P: FnMut(Self::Item) -> bool,
|
||||
{
|
||||
let mut i = 0;
|
||||
@ -752,7 +707,7 @@ fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
|
||||
P: FnMut(Self::Item) -> bool,
|
||||
Self: ExactSizeIterator + DoubleEndedIterator
|
||||
Self: Sized + ExactSizeIterator + DoubleEndedIterator
|
||||
{
|
||||
let mut i = self.len();
|
||||
|
||||
@ -775,7 +730,7 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn max(self) -> Option<Self::Item> where Self::Item: Ord
|
||||
fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
|
||||
{
|
||||
self.fold(None, |max, x| {
|
||||
match max {
|
||||
@ -795,7 +750,7 @@ fn max(self) -> Option<Self::Item> where Self::Item: Ord
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn min(self) -> Option<Self::Item> where Self::Item: Ord
|
||||
fn min(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
|
||||
{
|
||||
self.fold(None, |min, x| {
|
||||
match min {
|
||||
@ -837,7 +792,7 @@ fn min(self) -> Option<Self::Item> where Self::Item: Ord
|
||||
/// assert!(a.iter().min_max() == MinMax(&1, &1));
|
||||
/// ```
|
||||
#[unstable(feature = "core", reason = "return type may change")]
|
||||
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self::Item: Ord
|
||||
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
|
||||
{
|
||||
let (mut min, mut max) = match self.next() {
|
||||
None => return NoElements,
|
||||
@ -897,6 +852,7 @@ fn min_max(mut self) -> MinMaxResult<Self::Item> where Self::Item: Ord
|
||||
#[unstable(feature = "core",
|
||||
reason = "may want to produce an Ordering directly; see #15311")]
|
||||
fn max_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
|
||||
Self: Sized,
|
||||
F: FnMut(&Self::Item) -> B,
|
||||
{
|
||||
self.fold(None, |max: Option<(Self::Item, B)>, x| {
|
||||
@ -928,6 +884,7 @@ fn max_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
|
||||
#[unstable(feature = "core",
|
||||
reason = "may want to produce an Ordering directly; see #15311")]
|
||||
fn min_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
|
||||
Self: Sized,
|
||||
F: FnMut(&Self::Item) -> B,
|
||||
{
|
||||
self.fold(None, |min: Option<(Self::Item, B)>, x| {
|
||||
@ -957,7 +914,7 @@ fn min_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
|
||||
/// `std::usize::MAX` elements of the original iterator.
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn rev(self) -> Rev<Self> {
|
||||
fn rev(self) -> Rev<Self> where Self: Sized {
|
||||
Rev{iter: self}
|
||||
}
|
||||
|
||||
@ -979,7 +936,7 @@ fn rev(self) -> Rev<Self> {
|
||||
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
|
||||
FromA: Default + Extend<A>,
|
||||
FromB: Default + Extend<B>,
|
||||
Self: Iterator<Item=(A, B)>,
|
||||
Self: Sized + Iterator<Item=(A, B)>,
|
||||
{
|
||||
struct SizeHint<A>(usize, Option<usize>, marker::PhantomData<A>);
|
||||
impl<A> Iterator for SizeHint<A> {
|
||||
@ -1010,7 +967,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
/// converting an Iterator<&T> to an Iterator<T>.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
|
||||
where Self: Iterator<Item=&'a T>, T: Clone
|
||||
where Self: Sized + Iterator<Item=&'a T>, T: Clone
|
||||
{
|
||||
Cloned { it: self }
|
||||
}
|
||||
@ -1028,7 +985,7 @@ fn cloned<'a, T: 'a>(self) -> Cloned<Self>
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
fn cycle(self) -> Cycle<Self> where Self: Clone {
|
||||
fn cycle(self) -> Cycle<Self> where Self: Sized + Clone {
|
||||
Cycle{orig: self.clone(), iter: self}
|
||||
}
|
||||
|
||||
@ -1036,7 +993,7 @@ fn cycle(self) -> Cycle<Self> where Self: Clone {
|
||||
#[unstable(feature = "core",
|
||||
reason = "uncertain about placement or widespread use")]
|
||||
fn reverse_in_place<'a, T: 'a>(&mut self) where
|
||||
Self: Iterator<Item=&'a mut T> + DoubleEndedIterator
|
||||
Self: Sized + Iterator<Item=&'a mut T> + DoubleEndedIterator
|
||||
{
|
||||
loop {
|
||||
match (self.next(), self.next_back()) {
|
||||
@ -1048,7 +1005,55 @@ fn reverse_in_place<'a, T: 'a>(&mut self) where
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I> IteratorExt for I where I: Iterator {}
|
||||
impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
|
||||
type Item = I::Item;
|
||||
fn next(&mut self) -> Option<I::Item> { (**self).next() }
|
||||
fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
|
||||
}
|
||||
|
||||
/// Conversion from an `Iterator`
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
|
||||
built from an iterator over elements of type `{A}`"]
|
||||
pub trait FromIterator<A> {
|
||||
/// Build a container with elements from something iterable.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn from_iter<T: IntoIterator<Item=A>>(iterator: T) -> Self;
|
||||
}
|
||||
|
||||
/// Conversion into an `Iterator`
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait IntoIterator {
|
||||
/// The type of the elements being iterated
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
type Item;
|
||||
|
||||
/// A container for iterating over elements of type Item
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
type IntoIter: Iterator<Item=Self::Item>;
|
||||
|
||||
/// Consumes `Self` and returns an iterator over it
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn into_iter(self) -> Self::IntoIter;
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator> IntoIterator for I {
|
||||
type Item = I::Item;
|
||||
type IntoIter = I;
|
||||
|
||||
fn into_iter(self) -> I {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A type growable from an `Iterator` implementation
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait Extend<A> {
|
||||
/// Extend a container with the elements yielded by an arbitrary iterator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn extend<T: IntoIterator<Item=A>>(&mut self, iterable: T);
|
||||
}
|
||||
|
||||
/// A range iterator able to yield elements from both ends
|
||||
///
|
||||
@ -1256,7 +1261,7 @@ fn product(self) -> $A {
|
||||
impl_multiplicative! { f32, 1.0 }
|
||||
impl_multiplicative! { f64, 1.0 }
|
||||
|
||||
/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail.
|
||||
/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for more detail.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[unstable(feature = "core",
|
||||
reason = "unclear whether such a fine-grained result is widely useful")]
|
||||
|
@ -23,7 +23,7 @@
|
||||
use error::Error;
|
||||
use fmt;
|
||||
use intrinsics;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use marker::Copy;
|
||||
use mem::size_of;
|
||||
use ops::{Add, Sub, Mul, Div, Rem, Neg};
|
||||
|
@ -149,7 +149,7 @@
|
||||
use cmp::{Eq, Ord};
|
||||
use default::Default;
|
||||
use iter::ExactSizeIterator;
|
||||
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, IntoIterator};
|
||||
use iter::{Iterator, DoubleEndedIterator, FromIterator, IntoIterator};
|
||||
use mem;
|
||||
use ops::FnOnce;
|
||||
use result::Result::{Ok, Err};
|
||||
|
@ -37,7 +37,7 @@
|
||||
pub use clone::Clone;
|
||||
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
pub use convert::{AsRef, AsMut, Into, From};
|
||||
pub use iter::{Extend, IteratorExt};
|
||||
pub use iter::Extend;
|
||||
pub use iter::{Iterator, DoubleEndedIterator};
|
||||
pub use iter::{ExactSizeIterator};
|
||||
pub use option::Option::{self, Some, None};
|
||||
|
@ -243,8 +243,7 @@
|
||||
|
||||
use clone::Clone;
|
||||
use fmt;
|
||||
use iter::{Iterator, IteratorExt, DoubleEndedIterator,
|
||||
FromIterator, ExactSizeIterator, IntoIterator};
|
||||
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator};
|
||||
use ops::{FnMut, FnOnce};
|
||||
use option::Option::{self, None, Some};
|
||||
#[allow(deprecated)]
|
||||
|
@ -25,7 +25,7 @@
|
||||
use error::Error;
|
||||
use fmt;
|
||||
use iter::ExactSizeIterator;
|
||||
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
|
||||
use iter::{Map, Iterator, DoubleEndedIterator};
|
||||
use marker::Sized;
|
||||
use mem;
|
||||
#[allow(deprecated)]
|
||||
@ -1237,7 +1237,7 @@ pub struct CharRange {
|
||||
mod traits {
|
||||
use cmp::{Ordering, Ord, PartialEq, PartialOrd, Eq};
|
||||
use cmp::Ordering::{Less, Equal, Greater};
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use option::Option;
|
||||
use option::Option::Some;
|
||||
use ops;
|
||||
|
@ -20,7 +20,7 @@
|
||||
use default::Default;
|
||||
use fmt::{self, Debug};
|
||||
use hash::{Hash, SipHasher};
|
||||
use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
|
||||
use iter::{self, Iterator, ExactSizeIterator, IntoIterator, FromIterator, Extend, Map};
|
||||
use marker::Sized;
|
||||
use mem::{self, replace};
|
||||
use ops::{Deref, FnMut, FnOnce, Index};
|
||||
|
@ -18,9 +18,7 @@
|
||||
use fmt::Debug;
|
||||
use fmt;
|
||||
use hash::Hash;
|
||||
use iter::{
|
||||
Iterator, IntoIterator, ExactSizeIterator, IteratorExt, FromIterator, Map, Chain, Extend,
|
||||
};
|
||||
use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain, Extend};
|
||||
use ops::{BitOr, BitAnd, BitXor, Sub};
|
||||
use option::Option::{Some, None, self};
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
use clone::Clone;
|
||||
use cmp;
|
||||
use hash::{Hash, Hasher};
|
||||
use iter::{Iterator, IteratorExt, ExactSizeIterator, count};
|
||||
use iter::{Iterator, ExactSizeIterator, count};
|
||||
use marker::{Copy, Send, Sync, Sized, self};
|
||||
use mem::{min_align_of, size_of};
|
||||
use mem;
|
||||
|
@ -261,7 +261,7 @@ fn dlsym(handle: *mut libc::c_void,
|
||||
#[cfg(target_os = "windows")]
|
||||
mod dl {
|
||||
use ffi::OsStr;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use libc;
|
||||
use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED;
|
||||
use ops::FnOnce;
|
||||
|
@ -15,7 +15,7 @@
|
||||
use error::{Error, FromError};
|
||||
use fmt;
|
||||
use io;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use libc;
|
||||
use mem;
|
||||
#[allow(deprecated)]
|
||||
|
@ -16,7 +16,7 @@
|
||||
use unicode::str as core_str;
|
||||
use error as std_error;
|
||||
use fmt;
|
||||
use iter::{self, Iterator, IteratorExt, Extend};
|
||||
use iter::{self, Iterator, Extend};
|
||||
use marker::Sized;
|
||||
use ops::{Drop, FnOnce};
|
||||
use option::Option::{self, Some, None};
|
||||
|
@ -15,7 +15,7 @@
|
||||
use cmp;
|
||||
use fmt;
|
||||
use old_io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
|
||||
use iter::{IteratorExt, ExactSizeIterator, repeat};
|
||||
use iter::{Iterator, ExactSizeIterator, repeat};
|
||||
use ops::Drop;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
|
@ -400,7 +400,7 @@ mod test {
|
||||
extern crate test as test_crate;
|
||||
use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek, Buffer};
|
||||
use prelude::v1::{Ok, Err, Vec, AsSlice};
|
||||
use prelude::v1::IteratorExt;
|
||||
use prelude::v1::Iterator;
|
||||
use old_io;
|
||||
use iter::repeat;
|
||||
use self::test_crate::Bencher;
|
||||
|
@ -268,7 +268,7 @@
|
||||
use error::Error;
|
||||
use fmt;
|
||||
use isize;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use iter::Iterator;
|
||||
use marker::{PhantomFn, Sized};
|
||||
use mem::transmute;
|
||||
use ops::FnOnce;
|
||||
|
@ -19,7 +19,7 @@
|
||||
pub use self::Flag::*;
|
||||
pub use self::Protocol::*;
|
||||
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use old_io::IoResult;
|
||||
use old_io::net::ip::{SocketAddr, IpAddr};
|
||||
use option::Option;
|
||||
|
@ -21,7 +21,7 @@
|
||||
use fmt;
|
||||
use old_io::{self, IoResult, IoError};
|
||||
use old_io::net;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use iter::Iterator;
|
||||
use ops::{FnOnce, FnMut};
|
||||
use option::Option;
|
||||
use option::Option::{None, Some};
|
||||
|
@ -12,7 +12,7 @@
|
||||
#![allow(deprecated)] // rand
|
||||
|
||||
use env;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use old_io::{fs, IoError, IoErrorKind, IoResult};
|
||||
use old_io;
|
||||
use ops::Drop;
|
||||
|
@ -70,7 +70,7 @@
|
||||
use ffi::CString;
|
||||
use clone::Clone;
|
||||
use fmt;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use option::Option;
|
||||
use option::Option::{None, Some};
|
||||
use str;
|
||||
|
@ -16,7 +16,7 @@
|
||||
use hash;
|
||||
use old_io::Writer;
|
||||
use iter::{AdditiveIterator, Extend};
|
||||
use iter::{Iterator, IteratorExt, Map};
|
||||
use iter::{Iterator, Map};
|
||||
use marker::Sized;
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{self, Ok, Err};
|
||||
@ -444,13 +444,13 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use clone::Clone;
|
||||
use iter::IteratorExt;
|
||||
use option::Option::{self, Some, None};
|
||||
use old_path::GenericPath;
|
||||
use slice::AsSlice;
|
||||
use str::{self, Str};
|
||||
use string::ToString;
|
||||
use vec::Vec;
|
||||
use iter::Iterator;
|
||||
|
||||
macro_rules! t {
|
||||
(s: $path:expr, $exp:expr) => (
|
||||
|
@ -21,7 +21,7 @@
|
||||
use hash;
|
||||
use old_io::Writer;
|
||||
use iter::{AdditiveIterator, Extend};
|
||||
use iter::{Iterator, IteratorExt, Map, repeat};
|
||||
use iter::{Iterator, Map, repeat};
|
||||
use mem;
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{self, Ok, Err};
|
||||
@ -1126,7 +1126,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use clone::Clone;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
use option::Option::{self, Some, None};
|
||||
use old_path::GenericPath;
|
||||
use slice::AsSlice;
|
||||
|
@ -43,7 +43,7 @@
|
||||
use error::{FromError, Error};
|
||||
use ffi::{OsString, OsStr};
|
||||
use fmt;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use iter::Iterator;
|
||||
use libc::{c_void, c_int, c_char};
|
||||
use libc;
|
||||
use marker::{Copy, Send};
|
||||
|
@ -36,7 +36,7 @@
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use iter::ExactSizeIterator;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
|
||||
#[doc(no_inline)] pub use iter::{Iterator, Extend};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use option::Option::{self, Some, None};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -231,7 +231,7 @@
|
||||
use cell::RefCell;
|
||||
use clone::Clone;
|
||||
use old_io::IoResult;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use iter::Iterator;
|
||||
use mem;
|
||||
use rc::Rc;
|
||||
use result::Result::{Ok, Err};
|
||||
|
@ -127,7 +127,7 @@ pub fn spawn(cfg: &Command,
|
||||
|
||||
use env::split_paths;
|
||||
use mem;
|
||||
use iter::IteratorExt;
|
||||
use iter::Iterator;
|
||||
|
||||
// To have the spawning semantics of unix/windows stay the same, we need to
|
||||
// read the *child's* PATH if one is provided. See #15149 for more details.
|
||||
|
Loading…
Reference in New Issue
Block a user