From fd42ca5a25f8bab3ea66252f8bc0db02604f70dd Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 1 Aug 2024 16:11:15 +0200 Subject: feat(ecs): add relationships --- ecs/src/lock.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ecs/src/lock.rs') 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, -- cgit v1.2.3-18-g5258