diff options
| author | Mica White <botahamec@outlook.com> | 2026-08-16 12:43:05 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-08-16 12:43:05 -0400 |
| commit | 6f6e030ea7edb9d155ebf21b5d42936c20801b50 (patch) | |
| tree | f201f6536e3cb21786dc037570fba3f3ed2ff0e7 /src/collection/owned.rs | |
| parent | 482b47f4ed786946acb324b60d9f7ae7dd8cc075 (diff) | |
Implement LockContext
Diffstat (limited to 'src/collection/owned.rs')
| -rwxr-xr-x | src/collection/owned.rs | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/collection/owned.rs b/src/collection/owned.rs index a7ab1b6..07a5402 100755 --- a/src/collection/owned.rs +++ b/src/collection/owned.rs @@ -1,4 +1,4 @@ -use crate::iterator::LockingIterator; +use crate::iterator::LockContext; use crate::lockable::{ Lockable, LockableGetMut, LockableIntoInner, OwnedLockable, RawLock, Sharable, }; @@ -559,6 +559,10 @@ impl<L: Sharable> OwnedLockCollection<L> { } impl<L> OwnedLockCollection<L> { + pub const fn context(&self) -> LockContext<'_, L> { + LockContext::new(&self.child) + } + /// Gets the underlying collection, consuming this collection. /// /// # Examples @@ -641,27 +645,6 @@ impl<L: LockableIntoInner> OwnedLockCollection<L> { } } -impl<L: OwnedLockable> OwnedLockCollection<L> -where - for<'a> &'a L: IntoIterator, -{ - 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)] mod tests { use super::*; |
