From d6e6d4dbd7b2e34d11c61d1747304ef97ae6f1c1 Mon Sep 17 00:00:00 2001 From: Yjn024 Date: Wed, 6 Dec 2023 11:43:09 +0800 Subject: [PATCH] fix non-send future --- src/world/iter.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/world/iter.rs b/src/world/iter.rs index 4aa7ddb..90aa777 100644 --- a/src/world/iter.rs +++ b/src/world/iter.rs @@ -268,10 +268,11 @@ impl<'w, T: Data, const DIMS: usize, Io: IoHandle> Lazy<'w, T, DIMS, Io> { let chunk = self.world.load_chunk_buf(self.chunk).await; // Guard of a chunk. type Guard<'a, T> = RwLockReadGuard<'a, super::ChunkData>; + // SAFETY: wrapping lifetime to 'w. let guard: Arc> = Arc::new(std::mem::transmute(chunk.data.read().await)); - let lock = - &*(guard.get(&self.id).ok_or(crate::Error::ValueNotFound)? as *const RwLock>); + let lock: &'w RwLock> = + std::mem::transmute(guard.get(&self.id).ok_or(crate::Error::ValueNotFound)?); if let Some(LazyInner::Ref(val)) = self.value.get_mut() { val.guard = None;