1
1
mirror of https://github.com/casey/just.git synced 2024-11-22 02:09:44 +03:00

Implement FromIterator for AttributeSet

This commit is contained in:
Casey Rodarmor 2024-11-11 15:39:32 -08:00
parent c78467a171
commit 90537ca002
2 changed files with 5 additions and 4 deletions

View File

@ -148,11 +148,13 @@ impl<'src, 'a> IntoIterator for &'a AttributeSet<'src> {
}
}
impl<'src> AttributeSet<'src> {
pub(crate) fn from_iter(iter: impl IntoIterator<Item = Attribute<'src>>) -> Self {
impl<'src, 'a> FromIterator<Attribute<'src>> for AttributeSet<'src> {
fn from_iter<T: IntoIterator<Item = attribute::Attribute<'src>>>(iter: T) -> Self {
Self(iter.into_iter().collect())
}
}
impl<'src> AttributeSet<'src> {
pub(crate) fn len(&self) -> usize {
self.0.len()
}

View File

@ -1152,8 +1152,7 @@ impl<'run, 'src> Parser<'run, 'src> {
if attributes.is_empty() {
Ok(None)
} else {
let attribute_set = AttributeSet::from_iter(attributes.into_keys());
Ok(Some((token.unwrap(), attribute_set)))
Ok(Some((token.unwrap(), attributes.into_keys().collect())))
}
}
}