summaryrefslogtreecommitdiff
path: root/ecs/src/lock.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-01 16:11:15 +0200
committerHampusM <hampus@hampusmat.com>2024-08-02 15:34:54 +0200
commitfd42ca5a25f8bab3ea66252f8bc0db02604f70dd (patch)
tree6d384b5f462e2699342372f6b56791fc4607e9c6 /ecs/src/lock.rs
parent70c7d745f918dd23343599963a619539f4f880cb (diff)
feat(ecs): add relationships
Diffstat (limited to 'ecs/src/lock.rs')
-rw-r--r--ecs/src/lock.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/ecs/src/lock.rs b/ecs/src/lock.rs
index c8a8495..b3c9f57 100644
--- a/ecs/src/lock.rs
+++ b/ecs/src/lock.rs
@@ -1,3 +1,4 @@
+use std::mem::transmute;
use std::ops::{Deref, DerefMut};
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard, TryLockError};
@@ -73,6 +74,21 @@ where
inner: RwLockReadGuard<'guard, Value>,
}
+impl<'guard, Value> ReadGuard<'guard, Value>
+where
+ Value: TypeName,
+{
+ /// Converts the `ReadGuard` to a `ReadGuard` with a possibly longer lifetime.
+ ///
+ /// # Safety
+ /// The returned `ReadGuard` must **NOT** be used for longer than the original
+ /// lifetime.
+ pub unsafe fn upgrade_lifetime<'new>(self) -> ReadGuard<'new, Value>
+ {
+ unsafe { transmute(self) }
+ }
+}
+
impl<'guard, Value> Deref for ReadGuard<'guard, Value>
where
Value: TypeName,