auto merge of #19176 : aturon/rust/stab-iter, r=alexcrichton

This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](rust-lang/rfcs#445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]
This commit is contained in:
bors 2014-11-26 17:42:07 +00:00
commit 1a44875af9
59 changed files with 304 additions and 147 deletions

View File

@ -585,10 +585,10 @@ impl<T> DoubleEndedIterator<T> for MoveItems<T> {
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
}
impl<T> ExactSize<T> for MoveItems<T> {}
impl<T> ExactSizeIterator<T> for MoveItems<T> {}
impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> BinaryHeap<T> {
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> BinaryHeap<T> {
let vec: Vec<T> = iter.collect();
BinaryHeap::from_vec(vec)
}

View File

@ -68,7 +68,7 @@ use core::prelude::*;
use core::cmp;
use core::default::Default;
use core::fmt;
use core::iter::{Chain, Enumerate, Repeat, Skip, Take};
use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat};
use core::iter;
use core::num::Int;
use core::slice;
@ -88,11 +88,11 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
// have to uselessly pretend to pad the longer one for type matching
if a_len < b_len {
(a.mask_words(0).chain(Repeat::new(0u32).enumerate().take(b_len).skip(a_len)),
b.mask_words(0).chain(Repeat::new(0u32).enumerate().take(0).skip(0)))
(a.mask_words(0).chain(repeat(0u32).enumerate().take(b_len).skip(a_len)),
b.mask_words(0).chain(repeat(0u32).enumerate().take(0).skip(0)))
} else {
(a.mask_words(0).chain(Repeat::new(0u32).enumerate().take(0).skip(0)),
b.mask_words(0).chain(Repeat::new(0u32).enumerate().take(a_len).skip(b_len)))
(a.mask_words(0).chain(repeat(0u32).enumerate().take(0).skip(0)),
b.mask_words(0).chain(repeat(0u32).enumerate().take(a_len).skip(b_len)))
}
}
@ -943,7 +943,7 @@ impl<'a> DoubleEndedIterator<bool> for Bits<'a> {
}
}
impl<'a> ExactSize<bool> for Bits<'a> {}
impl<'a> ExactSizeIterator<bool> for Bits<'a> {}
impl<'a> RandomAccessIterator<bool> for Bits<'a> {
#[inline]

View File

@ -863,7 +863,7 @@ impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
// Note that the design of these iterators permits an *arbitrary* initial pair of min and max,
// making these arbitrary sub-range iterators. However the logic to construct these paths
// efficiently is fairly involved, so this is a FIXME. The sub-range iterators also wouldn't be
// able to accurately predict size, so those iterators can't implement ExactSize.
// able to accurately predict size, so those iterators can't implement ExactSizeIterator.
fn next(&mut self) -> Option<(K, V)> {
loop {
// We want the smallest element, so try to get the top of the left stack
@ -963,7 +963,7 @@ impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() }
}
impl<'a, K, V> ExactSize<(&'a K, &'a V)> for Entries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Entries<'a, K, V> {}
impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
@ -973,7 +973,7 @@ impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
}
impl<'a, K, V> ExactSize<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {}
impl<K, V> Iterator<(K, V)> for MoveEntries<K, V> {
@ -983,7 +983,7 @@ impl<K, V> Iterator<(K, V)> for MoveEntries<K, V> {
impl<K, V> DoubleEndedIterator<(K, V)> for MoveEntries<K, V> {
fn next_back(&mut self) -> Option<(K, V)> { self.inner.next_back() }
}
impl<K, V> ExactSize<(K, V)> for MoveEntries<K, V> {}
impl<K, V> ExactSizeIterator<(K, V)> for MoveEntries<K, V> {}

View File

@ -607,7 +607,7 @@ impl<'a, A> DoubleEndedIterator<&'a A> for Items<'a, A> {
}
}
impl<'a, A> ExactSize<&'a A> for Items<'a, A> {}
impl<'a, A> ExactSizeIterator<&'a A> for Items<'a, A> {}
impl<'a, A> Iterator<&'a mut A> for MutItems<'a, A> {
#[inline]
@ -645,7 +645,7 @@ impl<'a, A> DoubleEndedIterator<&'a mut A> for MutItems<'a, A> {
}
}
impl<'a, A> ExactSize<&'a mut A> for MutItems<'a, A> {}
impl<'a, A> ExactSizeIterator<&'a mut A> for MutItems<'a, A> {}
/// Allows mutating a `DList` while iterating.
pub trait ListInsertion<A> {

View File

@ -695,8 +695,7 @@ impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
}
}
impl<'a, T> ExactSize<&'a T> for Items<'a, T> {}
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
#[inline]
@ -763,7 +762,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> {
}
}
impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {}
impl<'a, T> ExactSizeIterator<&'a mut T> for MutItems<'a, T> {}
impl<A: PartialEq> PartialEq for RingBuf<A> {
fn eq(&self, other: &RingBuf<A>) -> bool {
@ -1322,7 +1321,7 @@ mod tests {
let u: Vec<int> = deq.iter().map(|&x| x).collect();
assert_eq!(u, v);
let mut seq = iter::count(0u, 2).take(256);
let seq = iter::count(0u, 2).take(256);
let deq: RingBuf<uint> = seq.collect();
for (i, &x) in deq.iter().enumerate() {
assert_eq!(2*i, x);

View File

@ -94,7 +94,7 @@ use core::cmp;
use core::kinds::Sized;
use core::mem::size_of;
use core::mem;
use core::prelude::{Clone, Greater, Iterator, Less, None, Option};
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
use core::prelude::{Ord, Ordering, RawPtr, Some, range};
use core::ptr;
use core::iter::{range_step, MultiplicativeIterator};

View File

@ -61,7 +61,7 @@ use core::cmp;
use core::iter::AdditiveIterator;
use core::kinds::Sized;
use core::prelude::{Char, Clone, Eq, Equiv};
use core::prelude::{Iterator, SlicePrelude, None, Option, Ord, Ordering};
use core::prelude::{Iterator, IteratorExt, SlicePrelude, None, Option, Ord, Ordering};
use core::prelude::{PartialEq, PartialOrd, Result, AsSlice, Some, Tuple2};
use core::prelude::{range};
@ -828,7 +828,7 @@ mod tests {
use std::cmp::{Equal, Greater, Less, Ord, PartialOrd, Equiv};
use std::option::{Some, None};
use std::ptr::RawPtr;
use std::iter::{Iterator, DoubleEndedIterator};
use std::iter::{Iterator, IteratorExt, DoubleEndedIteratorExt};
use super::*;
use std::slice::{AsSlice, SlicePrelude};
@ -2177,12 +2177,15 @@ mod tests {
let gr_inds = s.grapheme_indices(true).rev().collect::<Vec<(uint, &str)>>();
let b: &[_] = &[(11, "\r\n"), (6, "ö̲"), (3, ""), (0u, "")];
assert_eq!(gr_inds.as_slice(), b);
let mut gr_inds = s.grapheme_indices(true);
let e1 = gr_inds.size_hint();
assert_eq!(e1, (1, Some(13)));
let c = gr_inds.count();
assert_eq!(c, 4);
let e2 = gr_inds.size_hint();
let mut gr_inds_iter = s.grapheme_indices(true);
{
let gr_inds = gr_inds_iter.by_ref();
let e1 = gr_inds.size_hint();
assert_eq!(e1, (1, Some(13)));
let c = gr_inds.count();
assert_eq!(c, 4);
}
let e2 = gr_inds_iter.size_hint();
assert_eq!(e2, (0, Some(0)));
// make sure the reverse iterator does the right thing with "\n" at beginning of string
@ -2319,7 +2322,7 @@ mod bench {
use test::Bencher;
use test::black_box;
use super::*;
use std::iter::{Iterator, DoubleEndedIterator};
use std::iter::{IteratorExt, DoubleEndedIteratorExt};
use std::str::StrPrelude;
use std::slice::SlicePrelude;

View File

@ -1341,7 +1341,7 @@ impl<T> DoubleEndedIterator<T> for MoveItems<T> {
}
}
impl<T> ExactSize<T> for MoveItems<T> {}
impl<T> ExactSizeIterator<T> for MoveItems<T> {}
#[unsafe_destructor]
impl<T> Drop for MoveItems<T> {

View File

@ -17,7 +17,7 @@ pub use self::SignFormat::*;
use char;
use char::Char;
use fmt;
use iter::{range, DoubleEndedIterator};
use iter::{range, DoubleEndedIteratorExt};
use num::{Float, FPNaN, FPInfinite, ToPrimitive};
use num::cast;
use result::Ok;

View File

@ -14,7 +14,7 @@
use any;
use cell::{Cell, Ref, RefMut};
use iter::{Iterator, range};
use iter::{Iterator, IteratorExt, range};
use kinds::{Copy, Sized};
use mem;
use option::{Option, Some, None};

View File

@ -15,7 +15,7 @@
#![allow(unsigned_negation)]
use fmt;
use iter::DoubleEndedIterator;
use iter::DoubleEndedIteratorExt;
use num::{Int, cast};
use slice::SlicePrelude;

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ use clone::Clone;
use cmp::{PartialEq, Eq};
use cmp::{PartialOrd, Ord};
use intrinsics;
use iter::Iterator;
use iter::IteratorExt;
use kinds::Copy;
use mem::size_of;
use ops::{Add, Sub, Mul, Div, Rem, Neg};

View File

@ -147,7 +147,7 @@ pub use self::Option::*;
use cmp::{Eq, Ord};
use default::Default;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, ExactSizeIterator};
use mem;
use result::{Result, Ok, Err};
use slice;
@ -797,7 +797,7 @@ impl<A> DoubleEndedIterator<A> for Item<A> {
}
}
impl<A> ExactSize<A> for Item<A> {}
impl<A> ExactSizeIterator<A> for Item<A> {}
/////////////////////////////////////////////////////////////////////////////
// FromIterator

View File

@ -39,7 +39,7 @@ pub use ops::{Slice, SliceMut};
pub use ops::{Fn, FnMut, FnOnce};
// Reexported functions
pub use iter::{range, repeat};
pub use iter::range;
pub use mem::drop;
pub use str::from_str;
@ -50,9 +50,10 @@ pub use clone::Clone;
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
pub use cmp::{Ordering, Equiv};
pub use cmp::Ordering::{Less, Equal, Greater};
pub use iter::{FromIterator, Extend};
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
pub use iter::{FromIterator, Extend, IteratorExt};
pub use iter::{Iterator, DoubleEndedIterator, DoubleEndedIteratorExt, RandomAccessIterator};
pub use iter::{IteratorCloneExt, CloneIteratorExt};
pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
pub use num::{ToPrimitive, FromPrimitive};
pub use option::Option;
pub use option::Option::{Some, None};

View File

@ -235,7 +235,7 @@ pub use self::Result::*;
use std::fmt::Show;
use slice;
use slice::AsSlice;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, ExactSizeIterator};
use option::{None, Option, Some};
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
@ -831,7 +831,7 @@ impl<A> DoubleEndedIterator<A> for Item<A> {
}
}
impl<A> ExactSize<A> for Item<A> {}
impl<A> ExactSizeIterator<A> for Item<A> {}
/////////////////////////////////////////////////////////////////////////////
// FromIterator

View File

@ -1160,7 +1160,7 @@ impl<'a, T> Items<'a, T> {
iterator!{struct Items -> *const T, &'a T}
#[experimental = "needs review"]
impl<'a, T> ExactSize<&'a T> for Items<'a, T> {}
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
#[experimental = "needs review"]
impl<'a, T> Clone for Items<'a, T> {
@ -1255,7 +1255,7 @@ impl<'a, T> MutItems<'a, T> {
iterator!{struct MutItems -> *mut T, &'a mut T}
#[experimental = "needs review"]
impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {}
impl<'a, T> ExactSizeIterator<&'a mut T> for MutItems<'a, T> {}
/// An abstraction over the splitting iterators, so that splitn, splitn_mut etc
/// can be implemented once.

View File

@ -23,9 +23,9 @@ use char::Char;
use char;
use cmp::{Eq, mod};
use default::Default;
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
use iter::{DoubleEndedIteratorExt, ExactSizeIterator};
use iter::range;
use iter::{DoubleEndedIterator, ExactSize};
use iter::{Map, Iterator};
use kinds::Sized;
use mem;
use num::Int;
@ -1210,7 +1210,7 @@ Section: Trait implementations
#[allow(missing_docs)]
pub mod traits {
use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
use iter::Iterator;
use iter::IteratorExt;
use option::{Option, Some};
use ops;
use str::{Str, StrPrelude, eq_slice};

View File

@ -710,7 +710,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
let desc_sep = format!("\n{}", " ".repeat(24));
let mut rows = opts.iter().map(|optref| {
let rows = opts.iter().map(|optref| {
let OptGroup{short_name,
long_name,
hint,

View File

@ -11,8 +11,8 @@
//! The ISAAC random number generator.
use core::prelude::*;
use core::iter::{range_step, Repeat};
use core::slice;
use core::iter::{range_step, repeat};
use {Rng, SeedableRng, Rand};
@ -205,7 +205,7 @@ impl<'a> SeedableRng<&'a [u32]> for IsaacRng {
fn reseed(&mut self, seed: &'a [u32]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u32));
let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u32));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;
@ -438,7 +438,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng {
fn reseed(&mut self, seed: &'a [u64]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u64));
let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u64));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;

View File

@ -154,7 +154,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
pats: I,
pred: CFGIndex) -> CFGIndex {
//! Handles case where all of the patterns must match.
let mut pats = pats;
pats.fold(pred, |pred, pat| self.pat(&**pat, pred))
}
@ -527,7 +526,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
fn exprs<'a, I: Iterator<&'a ast::Expr>>(&mut self,
mut exprs: I,
exprs: I,
pred: CFGIndex) -> CFGIndex {
//! Constructs graph for `exprs` evaluated in order
exprs.fold(pred, |p, e| self.expr(e, p))

View File

@ -93,7 +93,7 @@ impl<'a> fmt::Show for Matrix<'a> {
}
impl<'a> FromIterator<Vec<&'a Pat>> for Matrix<'a> {
fn from_iter<T: Iterator<Vec<&'a Pat>>>(mut iterator: T) -> Matrix<'a> {
fn from_iter<T: Iterator<Vec<&'a Pat>>>(iterator: T) -> Matrix<'a> {
Matrix(iterator.collect())
}
}
@ -1091,4 +1091,3 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
}
}
}

View File

@ -80,7 +80,7 @@ pub fn join(a: constness, b: constness) -> constness {
}
}
pub fn join_all<It: Iterator<constness>>(mut cs: It) -> constness {
pub fn join_all<It: Iterator<constness>>(cs: It) -> constness {
cs.fold(integral_const, |a, b| join(a, b))
}

View File

@ -233,7 +233,7 @@ fn add_library(sess: &session::Session,
fn attempt_static(sess: &session::Session) -> Option<DependencyList> {
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
if crates.iter().all(|&(_, ref p)| p.is_some()) {
if crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) {
Some(crates.into_iter().map(|_| Some(cstore::RequireStatic)).collect())
} else {
None

View File

@ -80,7 +80,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
match item.node {
ItemFn(..) => {
if item.ident.name == ctxt.main_name {
ctxt.ast_map.with_path(item.id, |mut path| {
ctxt.ast_map.with_path(item.id, |path| {
if path.count() == 1 {
// This is a top-level function so can be 'main'
if ctxt.main_fn.is_none() {

View File

@ -132,7 +132,7 @@ pub fn simple_identifier<'a>(pat: &'a ast::Pat) -> Option<&'a ast::Ident> {
}
pub fn def_to_path(tcx: &ty::ctxt, id: ast::DefId) -> ast::Path {
ty::with_path(tcx, id, |mut path| ast::Path {
ty::with_path(tcx, id, |path| ast::Path {
global: false,
segments: path.last().map(|elem| ast::PathSegment {
identifier: ast::Ident::new(elem.name()),

View File

@ -3106,7 +3106,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
// Iterate until something non-representable is found
fn find_nonrepresentable<'tcx, It: Iterator<Ty<'tcx>>>(cx: &ctxt<'tcx>, sp: Span,
seen: &mut Vec<Ty<'tcx>>,
mut iter: It)
iter: It)
-> Representability {
iter.fold(Representable,
|r, ty| cmp::max(r, is_type_structurally_recursive(cx, sp, seen, ty)))
@ -3164,7 +3164,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
let types_a = substs_a.types.get_slice(subst::TypeSpace);
let types_b = substs_b.types.get_slice(subst::TypeSpace);
let mut pairs = types_a.iter().zip(types_b.iter());
let pairs = types_a.iter().zip(types_b.iter());
pairs.all(|(&a, &b)| same_type(a, b))
}

View File

@ -4177,7 +4177,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
ast::ExprMethodCall(ident, ref tps, ref args) => {
check_method_call(fcx, expr, ident, args.as_slice(), tps.as_slice(), lvalue_pref);
let mut arg_tys = args.iter().map(|a| fcx.expr_ty(&**a));
let arg_tys = args.iter().map(|a| fcx.expr_ty(&**a));
let args_err = arg_tys.fold(false,
|rest_err, a| {
rest_err || ty::type_is_error(a)});

View File

@ -170,7 +170,7 @@ impl<'a> FmtStrs<'a> {
});
let pairs = fields.iter().zip(values);
let mut strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape(
let strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape(
if *f == "qualname" && v.len() > 0 {
let mut n = self.krate.clone();
n.push_str("::");

View File

@ -2696,7 +2696,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId,
// Use provided name
Some(name) => name.get().to_string(),
_ => ccx.tcx().map.with_path(id, |mut path| {
_ => ccx.tcx().map.with_path(id, |path| {
if attr::contains_name(attrs, "no_mangle") {
// Don't mangle
path.last().unwrap().to_string()

View File

@ -151,7 +151,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
let def = ty::lookup_trait_def(tcx, did);
let trait_items = ty::trait_items(tcx, did).clean(cx);
let provided = ty::provided_trait_methods(tcx, did);
let mut items = trait_items.into_iter().map(|trait_item| {
let items = trait_items.into_iter().map(|trait_item| {
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
clean::ProvidedMethod(trait_item)
} else {

View File

@ -422,7 +422,7 @@ impl fmt::Show for clean::Type {
bounds = if decl.bounds.len() == 0 {
"".to_string()
} else {
let mut m = decl.bounds
let m = decl.bounds
.iter()
.map(|s| s.to_string());
format!(

View File

@ -183,7 +183,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
}
};
let mut lines = origtext.lines().filter(|l| {
let lines = origtext.lines().filter(|l| {
stripped_filtered_line(*l).is_none()
});
let text = lines.collect::<Vec<&str>>().connect("\n");
@ -325,7 +325,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
let opaque = opaque as *mut hoedown_html_renderer_state;
let tests = &mut *((*opaque).opaque as *mut ::test::Collector);
let text = str::from_utf8(text).unwrap();
let mut lines = text.lines().map(|l| {
let lines = text.lines().map(|l| {
stripped_filtered_line(l).unwrap_or(l)
});
let text = lines.collect::<Vec<&str>>().connect("\n");

View File

@ -19,7 +19,7 @@ use alloc::arc::Arc;
use alloc::boxed::Box;
use core::any::Any;
use core::atomic::{AtomicUint, SeqCst};
use core::iter::Take;
use core::iter::{IteratorExt, Take};
use core::kinds::marker;
use core::mem;
use core::prelude::{Clone, Drop, Err, Iterator, None, Ok, Option, Send, Some};

View File

@ -17,7 +17,7 @@
use core::kinds::Sized;
use fmt;
use iter::Iterator;
use iter::IteratorExt;
use mem;
use option::{Option, Some, None};
use slice::{SlicePrelude, AsSlice};

View File

@ -20,7 +20,7 @@ use cmp::{max, Eq, Equiv, PartialEq};
use default::Default;
use fmt::{mod, Show};
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{mod, Iterator, FromIterator, Extend};
use iter::{mod, Iterator, IteratorExt, FromIterator, Extend};
use kinds::Sized;
use mem::{mod, replace};
use num::UnsignedInt;

View File

@ -17,7 +17,7 @@ use default::Default;
use fmt::Show;
use fmt;
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{Iterator, FromIterator, FilterMap, Chain, Repeat, Zip, Extend};
use iter::{Iterator, IteratorExt, FromIterator, FilterMap, Chain, Repeat, Zip, Extend, repeat};
use iter;
use option::{Some, None};
use result::{Ok, Err};
@ -262,7 +262,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn difference<'a>(&'a self, other: &'a HashSet<T, H>) -> SetAlgebraItems<'a, T, H> {
Repeat::new(other).zip(self.iter())
repeat(other).zip(self.iter())
.filter_map(|(other, elt)| {
if !other.contains(elt) { Some(elt) } else { None }
})
@ -314,7 +314,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, H>)
-> SetAlgebraItems<'a, T, H> {
Repeat::new(other).zip(self.iter())
repeat(other).zip(self.iter())
.filter_map(|(other, elt)| {
if other.contains(elt) { Some(elt) } else { None }
})

View File

@ -21,7 +21,7 @@ A simple wrapper over the platform's dynamic library facilities
use clone::Clone;
use c_str::ToCStr;
use iter::Iterator;
use iter::IteratorExt;
use mem;
use ops::*;
use option::*;
@ -280,7 +280,7 @@ pub mod dl {
#[cfg(target_os = "windows")]
pub mod dl {
use c_str::ToCStr;
use iter::Iterator;
use iter::IteratorExt;
use libc;
use os;
use ptr;

View File

@ -14,7 +14,7 @@
use cmp;
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
use iter::ExactSize;
use iter::ExactSizeIterator;
use ops::Drop;
use option::{Some, None, Option};
use result::{Ok, Err};

View File

@ -233,7 +233,7 @@ use default::Default;
use error::{FromError, Error};
use fmt;
use int;
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use mem::transmute;
use ops::{BitOr, BitXor, BitAnd, Sub, Not};
use option::{Option, Some, None};

View File

@ -23,7 +23,7 @@ pub use self::SocketType::*;
pub use self::Flag::*;
pub use self::Protocol::*;
use iter::Iterator;
use iter::IteratorExt;
use io::{IoResult};
use io::net::ip::{SocketAddr, IpAddr};
use option::{Option, Some, None};

View File

@ -20,7 +20,7 @@ pub use self::IpAddr::*;
use fmt;
use io::{mod, IoResult, IoError};
use io::net;
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use option::{Option, None, Some};
use result::{Ok, Err};
use str::{FromStr, StrPrelude};

View File

@ -19,7 +19,6 @@
use clone::Clone;
use io::IoResult;
use iter::Iterator;
use result::Err;
use io::net::ip::{SocketAddr, ToSocketAddr};
use io::{Reader, Writer, Listener, Acceptor};

View File

@ -35,7 +35,6 @@ use failure::LOCAL_STDERR;
use fmt;
use io::{Reader, Writer, IoResult, IoError, OtherIoError,
standard_error, EndOfFile, LineBufferedWriter, BufferedReader};
use iter::Iterator;
use kinds::Send;
use libc;
use mem;

View File

@ -39,7 +39,7 @@ use clone::Clone;
use error::{FromError, Error};
use fmt;
use io::{IoResult, IoError};
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use libc::{c_void, c_int};
use libc;
use boxed::Box;

View File

@ -71,7 +71,7 @@ use core::kinds::Sized;
use c_str::CString;
use clone::Clone;
use fmt;
use iter::Iterator;
use iter::IteratorExt;
use option::{Option, None, Some};
use str;
use str::{CowString, MaybeOwned, Str, StrPrelude};

View File

@ -15,9 +15,10 @@ use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use hash;
use io::Writer;
use iter::{DoubleEndedIterator, AdditiveIterator, Extend, Iterator, Map};
use kinds::Sized;
use iter::{DoubleEndedIteratorExt, AdditiveIterator, Extend};
use iter::{Iterator, IteratorExt, Map};
use option::{Option, None, Some};
use kinds::Sized;
use str::{FromStr, Str};
use str;
use slice::{CloneSliceAllocPrelude, Splits, AsSlice, VectorVector,

View File

@ -20,7 +20,8 @@ use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use hash;
use io::Writer;
use iter::{AdditiveIterator, DoubleEndedIterator, Extend, Iterator, Map};
use iter::{AdditiveIterator, DoubleEndedIteratorExt, Extend};
use iter::{Iterator, IteratorExt, Map};
use mem;
use option::{Option, Some, None};
use slice::{AsSlice, SlicePrelude};

View File

@ -50,7 +50,7 @@
#[doc(no_inline)] pub use ops::{Fn, FnMut, FnOnce};
// Reexported functions
#[doc(no_inline)] pub use iter::{range, repeat};
#[doc(no_inline)] pub use iter::range;
#[doc(no_inline)] pub use mem::drop;
#[doc(no_inline)] pub use str::from_str;
@ -65,10 +65,11 @@
#[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
#[doc(no_inline)] pub use cmp::{Ordering, Equiv};
#[doc(no_inline)] pub use cmp::Ordering::{Less, Equal, Greater};
#[doc(no_inline)] pub use iter::{FromIterator, Extend, ExactSize};
#[doc(no_inline)] pub use iter::{Iterator, DoubleEndedIterator};
#[doc(no_inline)] pub use iter::{RandomAccessIterator, CloneableIterator};
#[doc(no_inline)] pub use iter::{OrdIterator, MutableDoubleEndedIterator};
#[doc(no_inline)] pub use iter::{FromIterator, Extend, ExactSizeIterator};
#[doc(no_inline)] pub use iter::{Iterator, IteratorExt, DoubleEndedIterator};
#[doc(no_inline)] pub use iter::{DoubleEndedIteratorExt, CloneIteratorExt};
#[doc(no_inline)] pub use iter::{RandomAccessIterator, IteratorCloneExt};
#[doc(no_inline)] pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator};
#[doc(no_inline)] pub use num::{ToPrimitive, FromPrimitive};
#[doc(no_inline)] pub use boxed::Box;
#[doc(no_inline)] pub use option::Option;

View File

@ -224,7 +224,7 @@
use cell::RefCell;
use clone::Clone;
use io::IoResult;
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use mem;
use rc::Rc;
use result::{Ok, Err};

View File

@ -13,7 +13,7 @@
#![allow(non_camel_case_types)]
use io::{IoResult, Writer};
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use option::{Some, None};
use os;
use result::{Ok, Err};
@ -388,7 +388,7 @@ mod imp {
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
use iter::Iterator;
use iter::IteratorExt;
use os;
use path::GenericPath;
use ptr::RawPtr;

View File

@ -131,7 +131,7 @@ extern "system" {
pub mod compat {
use intrinsics::{atomic_store_relaxed, transmute};
use iter::Iterator;
use iter::IteratorExt;
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
use prelude::*;

View File

@ -124,7 +124,7 @@ impl Process {
use libc::funcs::extra::msvcrt::get_osfhandle;
use mem;
use iter::Iterator;
use iter::{Iterator, IteratorExt};
use str::StrPrelude;
if cfg.gid().is_some() || cfg.uid().is_some() {

View File

@ -87,7 +87,7 @@ impl<'a, T: Copy> Iterator<T> for Values<'a, T> {
/// The type of the iterator used by with_path.
pub type PathElems<'a, 'b> = iter::Chain<Values<'a, PathElem>, LinkedPath<'b>>;
pub fn path_to_string<PI: Iterator<PathElem>>(mut path: PI) -> String {
pub fn path_to_string<PI: Iterator<PathElem>>(path: PI) -> String {
let itr = token::get_ident_interner();
path.fold(String::new(), |mut s, e| {

View File

@ -131,7 +131,7 @@ fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ {
ast::ItemStruct(fold_struct(cx, def), generics)
}
ast::ItemEnum(def, generics) => {
let mut variants = def.variants.into_iter().filter_map(|v| {
let variants = def.variants.into_iter().filter_map(|v| {
if !(cx.in_cfg)(v.node.attrs.as_slice()) {
None
} else {
@ -273,4 +273,3 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr
attr::cfg_matches(diagnostic, cfg, &*mis[0])
})
}

View File

@ -210,7 +210,7 @@ pub struct MacItems {
}
impl MacItems {
pub fn new<I: Iterator<P<ast::Item>>>(mut it: I) -> Box<MacResult+'static> {
pub fn new<I: Iterator<P<ast::Item>>>(it: I) -> Box<MacResult+'static> {
box MacItems { items: it.collect() } as Box<MacResult+'static>
}
}

View File

@ -580,7 +580,7 @@ impl<'a, 'b> Context<'a, 'b> {
let slicename = self.ecx.ident_of("__args_vec");
{
let args = names.into_iter().map(|a| a.unwrap());
let mut args = locals.into_iter().chain(args);
let args = locals.into_iter().chain(args);
let args = self.ecx.expr_vec_slice(self.fmtsp, args.collect());
lets.push(self.ecx.stmt_let(self.fmtsp, false, slicename, args));
}

View File

@ -145,7 +145,7 @@ impl<T: PartialEq> PartialEq for OwnedSlice<T> {
impl<T: Eq> Eq for OwnedSlice<T> {}
impl<T> FromIterator<T> for OwnedSlice<T> {
fn from_iter<I: Iterator<T>>(mut iter: I) -> OwnedSlice<T> {
fn from_iter<I: Iterator<T>>(iter: I) -> OwnedSlice<T> {
OwnedSlice::from_vec(iter.collect())
}
}

View File

@ -20,7 +20,8 @@
use self::GraphemeState::*;
use core::cmp;
use core::slice::SlicePrelude;
use core::iter::{Filter, AdditiveIterator, Iterator, DoubleEndedIterator};
use core::iter::{Filter, AdditiveIterator, Iterator, IteratorExt};
use core::iter::{DoubleEndedIterator, DoubleEndedIteratorExt};
use core::kinds::Sized;
use core::option::{Option, None, Some};
use core::str::{CharSplits, StrPrelude};