mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
FIXME: uint::range to vec`s iter().advance
This commit is contained in:
parent
0acb313c55
commit
0c1a277e8f
1 changed files with 6 additions and 8 deletions
|
@ -14,7 +14,6 @@ use layout_interface::{ContentBoxesResponse};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::comm::ChanOne;
|
use std::comm::ChanOne;
|
||||||
use std::comm;
|
use std::comm;
|
||||||
use std::uint;
|
|
||||||
use std::str::eq_slice;
|
use std::str::eq_slice;
|
||||||
use extra::net::url::Url;
|
use extra::net::url::Url;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
|
@ -136,9 +135,9 @@ impl<'self> Element {
|
||||||
|
|
||||||
pub fn get_attr(&'self self, name: &str) -> Option<&'self str> {
|
pub fn get_attr(&'self self, name: &str) -> Option<&'self str> {
|
||||||
// FIXME: Need an each() that links lifetimes in Rust.
|
// FIXME: Need an each() that links lifetimes in Rust.
|
||||||
for uint::range(0, self.attrs.len()) |i| {
|
for self.attrs.iter().advance |attr| {
|
||||||
if eq_slice(self.attrs[i].name, name) {
|
if eq_slice(attr.name, name) {
|
||||||
let val: &str = self.attrs[i].value;
|
let val: &str = attr.value;
|
||||||
return Some(val);
|
return Some(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,12 +147,11 @@ impl<'self> Element {
|
||||||
pub fn set_attr(&mut self, name: &DOMString, value: &DOMString) {
|
pub fn set_attr(&mut self, name: &DOMString, value: &DOMString) {
|
||||||
let name = name.to_str();
|
let name = name.to_str();
|
||||||
let value = value.to_str();
|
let value = value.to_str();
|
||||||
// FIXME: We need a better each_mut in Rust; this is ugly.
|
|
||||||
let value_cell = Cell::new(value);
|
let value_cell = Cell::new(value);
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
for uint::range(0, self.attrs.len()) |i| {
|
for self.attrs.mut_iter().advance |attr| {
|
||||||
if eq_slice(self.attrs[i].name, name) {
|
if eq_slice(attr.name, name) {
|
||||||
self.attrs[i].value = value_cell.take().clone();
|
attr.value = value_cell.take().clone();
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue