Skip to content

Commit

Permalink
fix non-send future
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Dec 6, 2023
1 parent de45575 commit d6e6d4d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/world/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>>;

// SAFETY: wrapping lifetime to 'w.
let guard: Arc<Guard<'w, T>> = Arc::new(std::mem::transmute(chunk.data.read().await));
let lock =
&*(guard.get(&self.id).ok_or(crate::Error::ValueNotFound)? as *const RwLock<Option<T>>);
let lock: &'w RwLock<Option<T>> =
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;
Expand Down

0 comments on commit d6e6d4d

Please sign in to comment.