diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-07-04 21:54:45 -0700 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-07-04 21:54:45 -0700 |
commit | a985ee4f190909cc853b9617ea45f2430e85033d (patch) | |
tree | 4d718b1615f10287a2c7581f617f0f3cd61ef72c /components/script/dom/attr.rs | |
parent | 236250c3fc7313346e490ce249083bb94d0dad74 (diff) | |
download | servo-a985ee4f190909cc853b9617ea45f2430e85033d.tar.gz servo-a985ee4f190909cc853b9617ea45f2430e85033d.zip |
Utilize iterators for AttrValue::from_serialized_tokenlist
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 6923c32c0ef..0c8e92f7d42 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -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) } |