Utilize iterators for AttrValue::from_serialized_tokenlist

This commit is contained in:
Corey Farwell 2015-07-04 21:54:45 -07:00
parent 236250c3fc
commit a985ee4f19

View file

@ -38,12 +38,13 @@ pub enum AttrValue {
impl AttrValue {
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
let mut atoms: Vec<Atom> = vec!();
for token in split_html_space_chars(&tokens).map(Atom::from_slice) {
if !atoms.iter().any(|atom| *atom == token) {
atoms.push(token);
}
}
let atoms =
split_html_space_chars(&tokens)
.map(Atom::from_slice)
.fold(vec![], |mut acc, atom| {
if !acc.contains(&atom) { acc.push(atom) }
acc
});
AttrValue::TokenList(tokens, atoms)
}