mirror of
https://github.com/servo/servo.git
synced 2025-07-29 18:20:24 +01:00
Utilize iterators for AttrValue::from_serialized_tokenlist
This commit is contained in:
parent
236250c3fc
commit
a985ee4f19
1 changed files with 7 additions and 6 deletions
|
@ -38,12 +38,13 @@ pub enum AttrValue {
|
||||||
|
|
||||||
impl AttrValue {
|
impl AttrValue {
|
||||||
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
|
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
|
||||||
let mut atoms: Vec<Atom> = vec!();
|
let atoms =
|
||||||
for token in split_html_space_chars(&tokens).map(Atom::from_slice) {
|
split_html_space_chars(&tokens)
|
||||||
if !atoms.iter().any(|atom| *atom == token) {
|
.map(Atom::from_slice)
|
||||||
atoms.push(token);
|
.fold(vec![], |mut acc, atom| {
|
||||||
}
|
if !acc.contains(&atom) { acc.push(atom) }
|
||||||
}
|
acc
|
||||||
|
});
|
||||||
AttrValue::TokenList(tokens, atoms)
|
AttrValue::TokenList(tokens, atoms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue