Skip to content

Commit

Permalink
feat(cordyceps): add iter::FromIterator for List (#232)
Browse files Browse the repository at this point in the history
This commit implements `core::iter::FromIterator<T::Handle>` for
`List<T>`.

Closes #226
  • Loading branch information
hawkw committed Jun 21, 2022
1 parent 1c59f93 commit d9bec37
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cordyceps/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,17 @@ where
// as well, so that we can just call `push_back` without looping.
}

impl<T> iter::FromIterator<T::Handle> for List<T>
where
T: Linked<Links<T>> + ?Sized,
{
fn from_iter<I: IntoIterator<Item = T::Handle>>(iter: I) -> Self {
let mut list = Self::new();
list.extend(iter);
list
}
}

unsafe impl<T: Linked<Links<T>> + ?Sized> Send for List<T> where T: Send {}
unsafe impl<T: Linked<Links<T>> + ?Sized> Sync for List<T> where T: Sync {}

Expand Down

0 comments on commit d9bec37

Please sign in to comment.