Replace uses of for foo in bar.iter() and for foo in bar.iter_mut()

closes #7197
This commit is contained in:
João Oliveira 2015-08-15 02:27:04 +01:00
parent 13e7de482c
commit 0038580abf
55 changed files with 141 additions and 154 deletions

View file

@ -259,7 +259,7 @@ impl CORSRequest {
// This cache should come from the user agent, creating a new one here to check
// for compile time errors
let cache = &mut CORSCache(vec!());
for m in methods.iter() {
for m in methods {
let cache_match = cache.match_method_and_update(self, m, max_age);
if !cache_match {
cache.insert(CORSCacheEntry::new(self.origin.clone(), self.destination.clone(),

View file

@ -158,7 +158,7 @@ pub fn handle_modify_attribute(page: &Rc<Page>,
let node = find_node_by_unique_id(&*page, pipeline, node_id);
let elem = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
for modification in modifications.iter(){
for modification in &modifications {
match modification.newValue {
Some(ref string) => {
let _ = elem.SetAttribute(modification.attributeName.clone(), string.clone());

View file

@ -386,7 +386,7 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) {
STACK_ROOTS.with(|ref collection| {
let RootCollectionPtr(collection) = collection.get().unwrap();
let collection = &*(*collection).roots.get();
for root in collection.iter() {
for root in collection {
trace_reflector(tracer, "reflector", &**root);
}
});

View file

@ -429,7 +429,7 @@ impl RootedTraceableSet {
}
unsafe fn trace(&self, tracer: *mut JSTracer) {
for info in self.set.iter() {
for info in &self.set {
(info.trace)(info.ptr, tracer);
}
}

View file

@ -235,7 +235,7 @@ pub fn do_create_interface_objects(cx: *mut JSContext,
members, s.as_ptr())
}
for ctor in named_constructors.iter() {
for ctor in named_constructors {
let (cnative, cname, cnargs) = *ctor;
let cs = CString::new(cname).unwrap();
@ -321,7 +321,7 @@ fn create_interface_object(cx: *mut JSContext,
/// Fails on JSAPI failure.
fn define_constants(cx: *mut JSContext, obj: HandleObject,
constants: &'static [ConstantSpec]) {
for spec in constants.iter() {
for spec in constants {
let value = RootedValue::new(cx, spec.get_value());
unsafe {
assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const libc::c_char,

View file

@ -752,7 +752,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
// Build a list of elements that are currently under the mouse.
let mouse_over_addresses = self.get_nodes_under_mouse(&point);
let mut mouse_over_targets: RootedVec<JS<Node>> = RootedVec::new();
for node_address in mouse_over_addresses.iter() {
for node_address in &mouse_over_addresses {
let node = node::from_untrusted_node_address(js_runtime, *node_address);
mouse_over_targets.push(node.r().inclusive_ancestors()
.find(|node| node.r().is_element())

View file

@ -101,7 +101,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
fn Add(self, tokens: Vec<DOMString>) -> ErrorResult {
let element = self.element.root();
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
for token in tokens.iter() {
for token in &tokens {
let token = try!(self.check_token_exceptions(&token));
if !atoms.iter().any(|atom| *atom == token) {
atoms.push(token);
@ -115,7 +115,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
fn Remove(self, tokens: Vec<DOMString>) -> ErrorResult {
let element = self.element.root();
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
for token in tokens.iter() {
for token in &tokens {
let token = try!(self.check_token_exceptions(&token));
atoms.iter().position(|atom| *atom == token).map(|index| {
atoms.remove(index)

View file

@ -45,7 +45,7 @@ pub fn dispatch_event<'a, 'b>(target: &'a EventTarget,
let stopped = match cur_target.get_listeners_for(&type_, ListenerPhase::Capturing) {
Some(listeners) => {
event.set_current_target(cur_target);
for listener in listeners.iter() {
for listener in &listeners {
// Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(*cur_target, event, Report);
@ -90,7 +90,7 @@ pub fn dispatch_event<'a, 'b>(target: &'a EventTarget,
let stopped = match cur_target.get_listeners_for(&type_, ListenerPhase::Bubbling) {
Some(listeners) => {
event.set_current_target(cur_target);
for listener in listeners.iter() {
for listener in &listeners {
// Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(*cur_target, event, Report);

View file

@ -350,7 +350,7 @@ impl<'a> HTMLFormElementHelpers for &'a HTMLFormElement {
// TODO: Handle `dirnames` (needs directionality support)
// https://html.spec.whatwg.org/multipage/#the-directionality
let mut ret: Vec<FormDatum> = data_set.collect();
for datum in ret.iter_mut() {
for datum in &mut ret {
match &*datum.ty {
"file" | "textarea" => (),
_ => {

View file

@ -380,7 +380,7 @@ impl<'a> VirtualMethods for &'a HTMLIFrameElement {
&atom!("sandbox") => {
let mut modes = SandboxAllowance::AllowNothing as u8;
if let Some(ref tokens) = attr.value().tokens() {
for token in tokens.iter() {
for token in *tokens {
modes |= match &*token.to_ascii_lowercase() {
"allow-same-origin" => SandboxAllowance::AllowSameOrigin,
"allow-forms" => SandboxAllowance::AllowForms,
@ -459,4 +459,3 @@ impl<'a> VirtualMethods for &'a HTMLIFrameElement {
}
}
}

View file

@ -1038,7 +1038,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
let mut encoding = UTF_8 as EncodingRef;
match self.response_headers.borrow().get() {
Some(&ContentType(mime::Mime(_, _, ref params))) => {
for &(ref name, ref value) in params.iter() {
for &(ref name, ref value) in params {
if name == &mime::Attr::Charset {
encoding = encoding_from_whatwg_label(&value.to_string()).unwrap_or(encoding);
}

View file

@ -266,4 +266,3 @@ impl TimerManager {
}
}
}