Add impl IntoIterator on &Classes (#3038)

This commit is contained in:
Cecile Tonglet 2022-12-13 22:07:16 +01:00 committed by GitHub
parent 9cd33e1dec
commit d14fcd2e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,6 +157,16 @@ impl IntoIterator for Classes {
}
}
impl IntoIterator for &Classes {
type IntoIter = indexmap::set::IntoIter<AttrValue>;
type Item = AttrValue;
#[inline]
fn into_iter(self) -> Self::IntoIter {
(*self.set).clone().into_iter()
}
}
impl ToString for Classes {
fn to_string(&self) -> String {
let mut iter = self.set.iter().cloned();
@ -347,6 +357,7 @@ mod tests {
other.push("foo");
other.push("bar");
let mut subject = Classes::new();
subject.extend(&other);
subject.extend(other);
assert!(subject.contains("foo"));
assert!(subject.contains("bar"));