Skip to content

Commit

Permalink
Merge pull request #27 from Kestrer/into-iter
Browse files Browse the repository at this point in the history
Implement IntoIterator for &ThreadLocal
  • Loading branch information
Amanieu authored Jan 23, 2021
2 parents c994299 + d779c7d commit 5b37741
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ impl<T: Send> IntoIterator for ThreadLocal<T> {
}
}

impl<'a, T: Send + Sync> IntoIterator for &'a ThreadLocal<T> {
type Item = &'a T;
type IntoIter = Iter<'a, T>;

fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

impl<'a, T: Send> IntoIterator for &'a mut ThreadLocal<T> {
type Item = &'a mut T;
type IntoIter = IterMut<'a, T>;
Expand Down

0 comments on commit 5b37741

Please sign in to comment.