for x in xs.into_iter()
-> for x in xs
Also `for x in option.into_iter()` -> `if let Some(x) = option`
This commit is contained in:
parent
d5f61b4332
commit
fd702702ee
@ -40,7 +40,7 @@ pub fn run(lib_path: &str,
|
||||
let mut cmd = Command::new(prog);
|
||||
cmd.args(args);
|
||||
add_target_env(&mut cmd, lib_path, aux_path);
|
||||
for (key, val) in env.into_iter() {
|
||||
for (key, val) in env {
|
||||
cmd.env(key, val);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ pub fn run_background(lib_path: &str,
|
||||
let mut cmd = Command::new(prog);
|
||||
cmd.args(args);
|
||||
add_target_env(&mut cmd, lib_path, aux_path);
|
||||
for (key, val) in env.into_iter() {
|
||||
for (key, val) in env {
|
||||
cmd.env(key, val);
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
|
||||
// run test via adb_run_wrapper
|
||||
runargs.push("shell".to_string());
|
||||
for (key, val) in env.into_iter() {
|
||||
for (key, val) in env {
|
||||
runargs.push(format!("{}={}", key, val));
|
||||
}
|
||||
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
|
||||
|
@ -197,7 +197,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
pub fn clear(&mut self) {
|
||||
let b = self.b;
|
||||
// avoid recursive destructors by manually traversing the tree
|
||||
for _ in mem::replace(self, BTreeMap::with_b(b)).into_iter() {};
|
||||
for _ in mem::replace(self, BTreeMap::with_b(b)) {};
|
||||
}
|
||||
|
||||
// Searching in a B-Tree is pretty straightforward.
|
||||
|
@ -1061,7 +1061,7 @@ mod tests {
|
||||
let mut sum = v;
|
||||
sum.push_all(u.as_slice());
|
||||
assert_eq!(sum.len(), m.len());
|
||||
for elt in sum.into_iter() {
|
||||
for elt in sum {
|
||||
assert_eq!(m.pop_front(), Some(elt))
|
||||
}
|
||||
assert_eq!(n.len(), 0);
|
||||
|
@ -2699,7 +2699,7 @@ mod tests {
|
||||
}
|
||||
assert_eq!(cnt, 8);
|
||||
|
||||
for f in v.into_iter() {
|
||||
for f in v {
|
||||
assert!(f == Foo);
|
||||
cnt += 1;
|
||||
}
|
||||
|
@ -2333,7 +2333,7 @@ mod tests {
|
||||
fn test_move_items() {
|
||||
let vec = vec![1, 2, 3];
|
||||
let mut vec2 : Vec<i32> = vec![];
|
||||
for i in vec.into_iter() {
|
||||
for i in vec {
|
||||
vec2.push(i);
|
||||
}
|
||||
assert!(vec2 == vec![1, 2, 3]);
|
||||
@ -2353,7 +2353,7 @@ mod tests {
|
||||
fn test_move_items_zero_sized() {
|
||||
let vec = vec![(), (), ()];
|
||||
let mut vec2 : Vec<()> = vec![];
|
||||
for i in vec.into_iter() {
|
||||
for i in vec {
|
||||
vec2.push(i);
|
||||
}
|
||||
assert!(vec2 == vec![(), (), ()]);
|
||||
|
@ -984,7 +984,7 @@ mod test_map {
|
||||
let mut m = VecMap::new();
|
||||
m.insert(1, box 2);
|
||||
let mut called = false;
|
||||
for (k, v) in m.into_iter() {
|
||||
for (k, v) in m {
|
||||
assert!(!called);
|
||||
called = true;
|
||||
assert_eq!(k, 1);
|
||||
|
@ -482,7 +482,7 @@ impl<'a> Formatter<'a> {
|
||||
|
||||
// Writes the sign if it exists, and then the prefix if it was requested
|
||||
let write_prefix = |&: f: &mut Formatter| {
|
||||
for c in sign.into_iter() {
|
||||
if let Some(c) = sign {
|
||||
let mut b = [0; 4];
|
||||
let n = c.encode_utf8(&mut b).unwrap_or(0);
|
||||
let b = unsafe { str::from_utf8_unchecked(&b[..n]) };
|
||||
|
@ -417,11 +417,11 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
|
||||
_ => sess.bug("impossible level in raw_emit_lint"),
|
||||
}
|
||||
|
||||
for note in note.into_iter() {
|
||||
if let Some(note) = note {
|
||||
sess.note(¬e[]);
|
||||
}
|
||||
|
||||
for span in def.into_iter() {
|
||||
if let Some(span) = def {
|
||||
sess.span_note(span, "lint level defined here");
|
||||
}
|
||||
}
|
||||
@ -492,7 +492,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
||||
// specified closure
|
||||
let mut pushed = 0;
|
||||
|
||||
for result in gather_attrs(attrs).into_iter() {
|
||||
for result in gather_attrs(attrs) {
|
||||
let v = match result {
|
||||
Err(span) => {
|
||||
self.tcx.sess.span_err(span, "malformed lint attribute");
|
||||
@ -519,7 +519,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
for (lint_id, level, span) in v.into_iter() {
|
||||
for (lint_id, level, span) in v {
|
||||
let now = self.lints.get_level_source(lint_id).0;
|
||||
if now == Forbid && level != Forbid {
|
||||
let lint_name = lint_id.as_str();
|
||||
@ -727,7 +727,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
|
||||
match self.tcx.sess.lints.borrow_mut().remove(&id) {
|
||||
None => {}
|
||||
Some(lints) => {
|
||||
for (lint_id, span, msg) in lints.into_iter() {
|
||||
for (lint_id, span, msg) in lints {
|
||||
self.span_lint(lint_id.lint, span, &msg[])
|
||||
}
|
||||
}
|
||||
|
@ -1589,7 +1589,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
|
||||
T: Hash<SipHasher>,
|
||||
{
|
||||
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
|
||||
for elt in index.into_iter() {
|
||||
for elt in index {
|
||||
let mut s = SipHasher::new();
|
||||
elt.val.hash(&mut s);
|
||||
let h = s.finish() as uint;
|
||||
|
@ -425,7 +425,7 @@ impl<'a> Context<'a> {
|
||||
// libraries corresponds to the crate id and hash criteria that this
|
||||
// search is being performed for.
|
||||
let mut libraries = Vec::new();
|
||||
for (_hash, (rlibs, dylibs)) in candidates.into_iter() {
|
||||
for (_hash, (rlibs, dylibs)) in candidates {
|
||||
let mut metadata = None;
|
||||
let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
|
||||
let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
|
||||
@ -501,7 +501,7 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
for (lib, kind) in m.into_iter() {
|
||||
for (lib, kind) in m {
|
||||
info!("{} reading metadata from: {}", flavor, lib.display());
|
||||
let metadata = match get_metadata_section(self.target.options.is_like_osx,
|
||||
&lib) {
|
||||
|
@ -77,7 +77,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
|
||||
let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1;
|
||||
let br = repeat('+').take(total_width).collect::<String>();
|
||||
try!(write!(f, "{}\n", br));
|
||||
for row in pretty_printed_matrix.into_iter() {
|
||||
for row in pretty_printed_matrix {
|
||||
try!(write!(f, "+"));
|
||||
for (column, pat_str) in row.into_iter().enumerate() {
|
||||
try!(write!(f, " "));
|
||||
|
@ -318,7 +318,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
|
||||
}
|
||||
|
||||
let dead_code = lint::builtin::DEAD_CODE.name_lower();
|
||||
for attr in lint::gather_attrs(attrs).into_iter() {
|
||||
for attr in lint::gather_attrs(attrs) {
|
||||
match attr {
|
||||
Ok((ref name, lint::Allow, _))
|
||||
if name.get() == dead_code => return true,
|
||||
|
@ -352,7 +352,7 @@ impl<T> VecPerParamSpace<T> {
|
||||
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
|
||||
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
|
||||
self.truncate(space, 0);
|
||||
for t in elems.into_iter() {
|
||||
for t in elems {
|
||||
self.push(space, t);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
let mut selcx = SelectionContext::new(infcx, typer);
|
||||
let normalized = project::normalize_projection_type(&mut selcx, projection_ty, cause, 0);
|
||||
|
||||
for obligation in normalized.obligations.into_iter() {
|
||||
for obligation in normalized.obligations {
|
||||
self.register_predicate_obligation(infcx, obligation);
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
|
||||
// Now go through all the successful ones,
|
||||
// registering any nested obligations for the future.
|
||||
for new_obligation in new_obligations.into_iter() {
|
||||
for new_obligation in new_obligations {
|
||||
self.register_predicate_obligation(selcx.infcx(), new_obligation);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ pub fn normalize_param_env<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx
|
||||
let mut fulfill_cx = FulfillmentContext::new();
|
||||
let Normalized { value: predicates, obligations } =
|
||||
project::normalize(selcx, cause, ¶m_env.caller_bounds);
|
||||
for obligation in obligations.into_iter() {
|
||||
for obligation in obligations {
|
||||
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
|
||||
}
|
||||
try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env));
|
||||
|
@ -204,7 +204,7 @@ impl<'a> PluginLoader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
for mut def in macros.into_iter() {
|
||||
for mut def in macros {
|
||||
let name = token::get_ident(def.ident);
|
||||
def.use_locally = match macro_selection.as_ref() {
|
||||
None => true,
|
||||
|
@ -300,7 +300,7 @@ macro_rules! options {
|
||||
pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
|
||||
{
|
||||
let mut op = $defaultfn();
|
||||
for option in matches.opt_strs($prefix).into_iter() {
|
||||
for option in matches.opt_strs($prefix) {
|
||||
let mut iter = option.splitn(1, '=');
|
||||
let key = iter.next().unwrap();
|
||||
let value = iter.next();
|
||||
@ -831,7 +831,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
let mut describe_lints = false;
|
||||
|
||||
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
|
||||
for lint_name in matches.opt_strs(level.as_str()).into_iter() {
|
||||
for lint_name in matches.opt_strs(level.as_str()) {
|
||||
if lint_name == "help" {
|
||||
describe_lints = true;
|
||||
} else {
|
||||
|
@ -424,7 +424,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
|
||||
diagnostics::plugin::expand_build_diagnostic_array);
|
||||
}
|
||||
|
||||
for registrar in registrars.into_iter() {
|
||||
for registrar in registrars {
|
||||
registry.args_hidden = Some(registrar.args);
|
||||
(registrar.fun)(&mut registry);
|
||||
}
|
||||
@ -434,11 +434,11 @@ pub fn phase_2_configure_and_expand(sess: &Session,
|
||||
|
||||
{
|
||||
let mut ls = sess.lint_store.borrow_mut();
|
||||
for pass in lint_passes.into_iter() {
|
||||
for pass in lint_passes {
|
||||
ls.register_pass(Some(sess), true, pass);
|
||||
}
|
||||
|
||||
for (name, to) in lint_groups.into_iter() {
|
||||
for (name, to) in lint_groups {
|
||||
ls.register_group(Some(sess), true, name, to);
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ Available lint options:
|
||||
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
|
||||
|
||||
let print_lints = |&: lints: Vec<&Lint>| {
|
||||
for lint in lints.into_iter() {
|
||||
for lint in lints {
|
||||
let name = lint.name_lower().replace("_", "-");
|
||||
println!(" {} {:7.7} {}",
|
||||
padded(&name[]), lint.default_level.as_str(), lint.desc);
|
||||
@ -400,7 +400,7 @@ Available lint options:
|
||||
println!(" {} {}", padded("----"), "---------");
|
||||
|
||||
let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| {
|
||||
for (name, to) in lints.into_iter() {
|
||||
for (name, to) in lints {
|
||||
let name = name.chars().map(|x| x.to_lowercase())
|
||||
.collect::<String>().replace("_", "-");
|
||||
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
|
||||
|
@ -3607,10 +3607,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
TyQPath(ref qpath) => {
|
||||
self.resolve_type(&*qpath.self_type);
|
||||
self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath);
|
||||
for ty in qpath.item_path.parameters.types().into_iter() {
|
||||
for ty in qpath.item_path.parameters.types() {
|
||||
self.resolve_type(&**ty);
|
||||
}
|
||||
for binding in qpath.item_path.parameters.bindings().into_iter() {
|
||||
for binding in qpath.item_path.parameters.bindings() {
|
||||
self.resolve_type(&*binding.ty);
|
||||
}
|
||||
}
|
||||
|
@ -1275,7 +1275,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
|
||||
// we're just getting an ordering of crate numbers, we're not worried about
|
||||
// the paths.
|
||||
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
|
||||
for (cnum, _) in crates.into_iter() {
|
||||
for (cnum, _) in crates {
|
||||
let libs = csearch::get_native_libraries(&sess.cstore, cnum);
|
||||
for &(kind, ref lib) in &libs {
|
||||
match kind {
|
||||
|
@ -48,7 +48,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
// load the bitcode from the archive. Then merge it into the current LLVM
|
||||
// module that we've got.
|
||||
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
|
||||
for (cnum, path) in crates.into_iter() {
|
||||
for (cnum, path) in crates {
|
||||
let name = sess.cstore.get_crate_data(cnum).name.clone();
|
||||
let path = match path {
|
||||
Some(p) => p,
|
||||
|
@ -941,7 +941,7 @@ fn run_work_multithreaded(sess: &Session,
|
||||
}
|
||||
|
||||
let mut panicked = false;
|
||||
for rx in futures.into_iter() {
|
||||
for rx in futures {
|
||||
match rx.recv() {
|
||||
Ok(()) => {},
|
||||
Err(_) => {
|
||||
|
@ -1045,7 +1045,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
}));
|
||||
|
||||
assert_eq!(arg_tys.len(), 1 + rhs.len());
|
||||
for (rhs, rhs_id) in rhs.into_iter() {
|
||||
for (rhs, rhs_id) in rhs {
|
||||
llargs.push(unpack_result!(bcx, {
|
||||
trans_arg_datum(bcx, arg_tys[1], rhs,
|
||||
arg_cleanup_scope,
|
||||
|
@ -333,7 +333,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
|
||||
obligations.repr(tcx));
|
||||
|
||||
let mut fulfill_cx = traits::FulfillmentContext::new();
|
||||
for obligation in obligations.into_iter() {
|
||||
for obligation in obligations {
|
||||
fulfill_cx.register_predicate_obligation(&infcx, obligation);
|
||||
}
|
||||
let result = drain_fulfillment_cx(DUMMY_SP, &infcx, &mut fulfill_cx, &result);
|
||||
|
@ -537,7 +537,7 @@ pub fn instantiate_poly_trait_ref<'tcx>(
|
||||
instantiate_trait_ref(this, &shifted_rscope, &ast_trait_ref.trait_ref,
|
||||
self_ty, Some(&mut projections));
|
||||
|
||||
for projection in projections.into_iter() {
|
||||
for projection in projections {
|
||||
poly_projections.push(ty::Binder(projection));
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
||||
debug!("normalize_associated_types_in: result={} predicates={}",
|
||||
result.repr(infcx.tcx),
|
||||
obligations.repr(infcx.tcx));
|
||||
for obligation in obligations.into_iter() {
|
||||
for obligation in obligations {
|
||||
fulfillment_cx.register_predicate_obligation(infcx, obligation);
|
||||
}
|
||||
result
|
||||
|
@ -248,7 +248,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
|
||||
let mut selcx = traits::SelectionContext::new(&infcx, &trait_param_env);
|
||||
|
||||
for predicate in impl_pred.fns.into_iter() {
|
||||
for predicate in impl_pred.fns {
|
||||
let traits::Normalized { value: predicate, .. } =
|
||||
traits::normalize(&mut selcx, normalize_cause.clone(), &predicate);
|
||||
|
||||
|
@ -448,7 +448,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
||||
{
|
||||
let mut duplicates = HashSet::new();
|
||||
let opt_applicable_traits = self.fcx.ccx.trait_map.get(&expr_id);
|
||||
for applicable_traits in opt_applicable_traits.into_iter() {
|
||||
if let Some(applicable_traits) = opt_applicable_traits {
|
||||
for &trait_did in applicable_traits {
|
||||
if duplicates.insert(trait_did) {
|
||||
try!(self.assemble_extension_candidates_for_trait(trait_did));
|
||||
|
@ -142,7 +142,7 @@ pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
ty::item_path_str(tcx, object_trait_ref.def_id()));
|
||||
|
||||
let violations = traits::object_safety_violations(tcx, object_trait_ref.clone());
|
||||
for violation in violations.into_iter() {
|
||||
for violation in violations {
|
||||
match violation {
|
||||
ObjectSafetyViolation::SizedSelf => {
|
||||
tcx.sess.span_note(
|
||||
@ -269,7 +269,7 @@ fn check_object_type_binds_all_associated_types<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
associated_types.remove(&pair);
|
||||
}
|
||||
|
||||
for (trait_def_id, name) in associated_types.into_iter() {
|
||||
for (trait_def_id, name) in associated_types {
|
||||
span_err!(tcx.sess, span, E0191,
|
||||
"the value of the associated type `{}` (from the trait `{}`) must be specified",
|
||||
name.user_string(tcx),
|
||||
|
@ -268,10 +268,10 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx);
|
||||
traits::normalize(selcx, cause.clone(), &predicates)
|
||||
};
|
||||
for predicate in predicates.value.into_iter() {
|
||||
for predicate in predicates.value {
|
||||
fcx.register_predicate(traits::Obligation::new(cause.clone(), predicate));
|
||||
}
|
||||
for obligation in predicates.obligations.into_iter() {
|
||||
for obligation in predicates.obligations {
|
||||
fcx.register_predicate(obligation);
|
||||
}
|
||||
});
|
||||
|
@ -1109,7 +1109,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
|
||||
|
||||
debug!("ty_generics_for_trait: assoc_predicates={}", assoc_predicates.repr(ccx.tcx));
|
||||
|
||||
for assoc_predicate in assoc_predicates.into_iter() {
|
||||
for assoc_predicate in assoc_predicates {
|
||||
generics.predicates.push(subst::TypeSpace, assoc_predicate);
|
||||
}
|
||||
|
||||
@ -1310,7 +1310,7 @@ fn ty_generics<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
|
||||
{
|
||||
for type_param_def in result.types.get_slice(space) {
|
||||
let param_ty = ty::mk_param_from_def(tcx, type_param_def);
|
||||
for predicate in ty::predicates(tcx, param_ty, &type_param_def.bounds).into_iter() {
|
||||
for predicate in ty::predicates(tcx, param_ty, &type_param_def.bounds) {
|
||||
result.predicates.push(space, predicate);
|
||||
}
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ impl Context {
|
||||
_ => unreachable!()
|
||||
};
|
||||
this.sidebar = this.build_sidebar(&m);
|
||||
for item in m.items.into_iter() {
|
||||
for item in m.items {
|
||||
f(this,item);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -431,7 +431,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
||||
pm.add_plugin(plugin);
|
||||
}
|
||||
info!("loading plugins...");
|
||||
for pname in plugins.into_iter() {
|
||||
for pname in plugins {
|
||||
pm.load_plugin(pname);
|
||||
}
|
||||
|
||||
|
@ -2371,7 +2371,7 @@ impl ::Decoder for Decoder {
|
||||
{
|
||||
let obj = try!(expect!(self.pop(), Object));
|
||||
let len = obj.len();
|
||||
for (key, value) in obj.into_iter() {
|
||||
for (key, value) in obj {
|
||||
self.stack.push(value);
|
||||
self.stack.push(Json::String(key));
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
|
||||
|
||||
// delete all regular files in the way and push subdirs
|
||||
// on the stack
|
||||
for child in children.into_iter() {
|
||||
for child in children {
|
||||
// FIXME(#12795) we should use lstat in all cases
|
||||
let child_type = match cfg!(windows) {
|
||||
true => try!(update_err(stat(&child), path)),
|
||||
|
@ -36,7 +36,7 @@ fn with_addresses<A, T, F>(addr: A, mut action: F) -> IoResult<T> where
|
||||
|
||||
let addresses = try!(addr.to_socket_addr_all());
|
||||
let mut err = DEFAULT_ERROR;
|
||||
for addr in addresses.into_iter() {
|
||||
for addr in addresses {
|
||||
match action(addr) {
|
||||
Ok(r) => return Ok(r),
|
||||
Err(e) => err = e
|
||||
|
@ -58,7 +58,7 @@ pub fn cleanup() {
|
||||
// If we never called init, not need to cleanup!
|
||||
if queue as uint != 0 {
|
||||
let queue: Box<Queue> = mem::transmute(queue);
|
||||
for to_run in queue.into_iter() {
|
||||
for to_run in *queue {
|
||||
to_run.invoke(());
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Wait for children to pass their asserts
|
||||
for r in children.into_iter() {
|
||||
for r in children {
|
||||
assert!(r.join().is_ok());
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ impl Process {
|
||||
|
||||
// Split the value and test each path to see if the
|
||||
// program exists.
|
||||
for path in os::split_paths(v.container_as_bytes()).into_iter() {
|
||||
for path in os::split_paths(v.container_as_bytes()) {
|
||||
let path = path.join(cfg.program().as_bytes())
|
||||
.with_extension(os::consts::EXE_EXTENSION);
|
||||
if path.exists() {
|
||||
|
@ -490,7 +490,7 @@ fn find_stability_generic<'a,
|
||||
pub fn find_stability(diagnostic: &SpanHandler, attrs: &[Attribute],
|
||||
item_sp: Span) -> Option<Stability> {
|
||||
let (s, used) = find_stability_generic(diagnostic, attrs.iter(), item_sp);
|
||||
for used in used.into_iter() { mark_used(used) }
|
||||
for used in used { mark_used(used) }
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
||||
None => return base::DummyResult::expr(sp)
|
||||
};
|
||||
let mut accumulator = String::new();
|
||||
for e in es.into_iter() {
|
||||
for e in es {
|
||||
match e.node {
|
||||
ast::ExprLit(ref lit) => {
|
||||
match lit.node {
|
||||
|
@ -1420,11 +1420,11 @@ pub fn expand_crate(parse_sess: &parse::ParseSess,
|
||||
let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg);
|
||||
let mut expander = MacroExpander::new(&mut cx);
|
||||
|
||||
for def in imported_macros.into_iter() {
|
||||
for def in imported_macros {
|
||||
expander.cx.insert_macro(def);
|
||||
}
|
||||
|
||||
for (name, extension) in user_exts.into_iter() {
|
||||
for (name, extension) in user_exts {
|
||||
expander.cx.syntax_env.insert(name, extension);
|
||||
}
|
||||
|
||||
|
@ -5445,7 +5445,7 @@ impl<'a> Parser<'a> {
|
||||
seq_sep_trailing_allowed(token::Comma),
|
||||
|p| p.parse_ty_sum()
|
||||
);
|
||||
for ty in arg_tys.into_iter() {
|
||||
for ty in arg_tys {
|
||||
args.push(ast::VariantArg {
|
||||
ty: ty,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
|
@ -966,7 +966,7 @@ impl<'a> State<'a> {
|
||||
try!(self.print_generics(generics));
|
||||
let bounds: Vec<_> = bounds.iter().map(|b| b.clone()).collect();
|
||||
let mut real_bounds = Vec::with_capacity(bounds.len());
|
||||
for b in bounds.into_iter() {
|
||||
for b in bounds {
|
||||
if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = b {
|
||||
try!(space(&mut self.s));
|
||||
try!(self.word_space("for ?"));
|
||||
|
@ -806,7 +806,7 @@ fn run_tests<F>(opts: &TestOpts,
|
||||
|
||||
// All benchmarks run at the end, in serial.
|
||||
// (this includes metric fns)
|
||||
for b in filtered_benchs_and_metrics.into_iter() {
|
||||
for b in filtered_benchs_and_metrics {
|
||||
try!(callback(TeWait(b.desc.clone(), b.testfn.padding())));
|
||||
run_test(opts, !opts.run_benchmarks, b, tx.clone());
|
||||
let (test, result, stdout) = rx.recv().unwrap();
|
||||
|
@ -177,7 +177,7 @@ impl Subcommand for Build {
|
||||
}
|
||||
Err(errors) => {
|
||||
let n = errors.len();
|
||||
for err in errors.into_iter() {
|
||||
for err in errors {
|
||||
term.err(&format!("error: {}", err)[]);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ impl Subcommand for Test {
|
||||
}
|
||||
}
|
||||
Err(errors) => {
|
||||
for err in errors.into_iter() {
|
||||
for err in errors {
|
||||
term.err(&err[]);
|
||||
}
|
||||
return Err(box "There was an error." as Box<Error>);
|
||||
|
@ -75,7 +75,7 @@ fn run(args: &[String]) {
|
||||
server(&from_parent, &to_parent);
|
||||
});
|
||||
|
||||
for r in worker_results.into_iter() {
|
||||
for r in worker_results {
|
||||
let _ = r.join();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ fn run(args: &[String]) {
|
||||
server(&from_parent, &to_parent);
|
||||
});
|
||||
|
||||
for r in worker_results.into_iter() {
|
||||
for r in worker_results {
|
||||
let _ = r.join();
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ fn main() {
|
||||
Thread::scoped(move || inner(depth, iterations))
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
for message in messages.into_iter() {
|
||||
for message in messages {
|
||||
println!("{}", message.join().ok().unwrap());
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
||||
|
||||
let mut checksum = 0;
|
||||
let mut maxflips = 0;
|
||||
for fut in futures.into_iter() {
|
||||
for fut in futures {
|
||||
let (cs, mf) = fut.join().ok().unwrap();
|
||||
checksum += cs;
|
||||
maxflips = cmp::max(maxflips, mf);
|
||||
|
@ -308,7 +308,7 @@ fn main() {
|
||||
Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len()))
|
||||
}).collect();
|
||||
|
||||
for (i, freq) in nb_freqs.into_iter() {
|
||||
for (i, freq) in nb_freqs {
|
||||
print_frequencies(&freq.join().ok().unwrap(), i);
|
||||
}
|
||||
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {
|
||||
|
@ -106,7 +106,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
for res in precalc_futures.into_iter() {
|
||||
for res in precalc_futures {
|
||||
let (rs, is) = res.join().ok().unwrap();
|
||||
precalc_r.extend(rs.into_iter());
|
||||
precalc_i.extend(is.into_iter());
|
||||
@ -142,7 +142,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
|
||||
for res in data.into_iter() {
|
||||
for res in data {
|
||||
try!(out.write(res.join().ok().unwrap().as_slice()));
|
||||
}
|
||||
out.flush()
|
||||
|
@ -82,7 +82,7 @@ fn stress(num_tasks: int) {
|
||||
stress_task(i);
|
||||
}));
|
||||
}
|
||||
for r in results.into_iter() {
|
||||
for r in results {
|
||||
let _ = r.join();
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ fn main() {
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
for simple_tuple_ident in vec![(34903493u32, 232323i64)].into_iter() {
|
||||
for simple_tuple_ident in vec![(34903493u32, 232323i64)] {
|
||||
zzz(); // #break
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ fn test00() {
|
||||
}
|
||||
|
||||
// Join spawned tasks...
|
||||
for r in results.into_iter() { r.join(); }
|
||||
for r in results { r.join(); }
|
||||
|
||||
println!("Completed: Final number is: ");
|
||||
println!("{}", sum);
|
||||
|
@ -21,7 +21,7 @@ fn main() {
|
||||
call(|| {
|
||||
// Move `y`, but do not move `counter`, even though it is read
|
||||
// by value (note that it is also mutated).
|
||||
for item in y.into_iter() {
|
||||
for item in y {
|
||||
let v = counter;
|
||||
counter += v;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fn main() {
|
||||
// Here: `x` must be captured with a mutable reference in
|
||||
// order for us to append on it, and `y` must be captured by
|
||||
// value.
|
||||
for item in y.into_iter() {
|
||||
for item in y {
|
||||
x.push(item);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user