From d021a3c3748ca921fa7c0aa94bfb09e6f30090d0 Mon Sep 17 00:00:00 2001 From: Alexander Sepity Date: Mon, 15 Feb 2021 03:20:16 +0300 Subject: [PATCH] Relaxed bounds on `NonSend`. (#1448) --- crates/bevy_ecs/src/resource/resource_query.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/resource/resource_query.rs b/crates/bevy_ecs/src/resource/resource_query.rs index 6cd55a1d4a338..b06c9a75e8a8f 100644 --- a/crates/bevy_ecs/src/resource/resource_query.rs +++ b/crates/bevy_ecs/src/resource/resource_query.rs @@ -136,12 +136,12 @@ impl<'a, T: Resource + FromResources> DerefMut for Local<'a, T> { /// `NonSend` resources cannot leave the main thread, so any system that wants access to /// a non-send resource will run on the main thread. See `Resources::insert_non_send()` and friends. #[derive(Debug)] -pub struct NonSend<'a, T: Resource> { +pub struct NonSend<'a, T: 'static> { value: *mut T, _marker: PhantomData<&'a T>, } -impl<'a, T: Resource> NonSend<'a, T> { +impl<'a, T: 'static> NonSend<'a, T> { pub(crate) unsafe fn new(resources: &Resources) -> Self { NonSend { value: resources.get_unsafe_non_send_ref::().as_ptr(), @@ -150,7 +150,7 @@ impl<'a, T: Resource> NonSend<'a, T> { } } -impl<'a, T: Resource> Deref for NonSend<'a, T> { +impl<'a, T: 'static> Deref for NonSend<'a, T> { type Target = T; fn deref(&self) -> &T { @@ -158,7 +158,7 @@ impl<'a, T: Resource> Deref for NonSend<'a, T> { } } -impl<'a, T: Resource> DerefMut for NonSend<'a, T> { +impl<'a, T: 'static> DerefMut for NonSend<'a, T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.value } }