summaryrefslogtreecommitdiff
path: root/src/collection/owned.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/collection/owned.rs')
-rw-r--r--src/collection/owned.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/collection/owned.rs b/src/collection/owned.rs
index 59e1ff8..3d6fa93 100644
--- a/src/collection/owned.rs
+++ b/src/collection/owned.rs
@@ -128,11 +128,9 @@ impl<E: OwnedLockable + Extend<L>, L: OwnedLockable> Extend<L> for OwnedLockColl
}
}
-impl<T, L: AsRef<T>> AsRef<T> for OwnedLockCollection<L> {
- fn as_ref(&self) -> &T {
- self.data.as_ref()
- }
-}
+// AsRef can't be implemented because an impl of AsRef<L> for L could break the
+// invariant that there is only one way to lock the collection. AsMut is fine,
+// because the collection can't be locked as long as the reference is valid.
impl<T, L: AsMut<T>> AsMut<T> for OwnedLockCollection<L> {
fn as_mut(&mut self) -> &mut T {
@@ -416,6 +414,10 @@ impl<L> OwnedLockCollection<L> {
pub fn into_child(self) -> L {
self.data
}
+
+ pub fn child_mut(&mut self) -> &mut L {
+ &mut self.data
+ }
}
impl<L: LockableGetMut> OwnedLockCollection<L> {