diff options
Diffstat (limited to 'src/collection')
| -rwxr-xr-x | src/collection/owned.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/collection/owned.rs b/src/collection/owned.rs index 2172b96..516f1ea 100755 --- a/src/collection/owned.rs +++ b/src/collection/owned.rs @@ -647,9 +647,21 @@ impl<L: OwnedLockable> OwnedLockCollection<L> where for<'a> &'a L: IntoIterator, { - pub fn locking_iter(&self, key: ThreadKey) -> LockingIterator<<&L as IntoIterator>::IntoIter> { + pub fn locking_iter( + &self, + key: ThreadKey, + ) -> LockingIterator<<&L as IntoIterator>::IntoIter, ThreadKey> { LockingIterator::new(key, (&self.child).into_iter()) } + + pub fn scoped_locking_iter<Key: Keyable, R>( + &self, + key: Key, + f: impl FnOnce(&mut LockingIterator<<&L as IntoIterator>::IntoIter, Key>) -> R, + ) -> R { + let mut iterator = LockingIterator::new(key, (&self.child).into_iter()); + f(&mut iterator) + } } #[cfg(test)] |
