Skip to content

Commit

Permalink
Relaxed bounds on NonSend. (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratysz authored Feb 15, 2021
1 parent f8292cc commit d021a3c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/resource/resource_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ impl<'a, T: Resource + FromResources> DerefMut for Local<'a, T> {
/// `NonSend<T>` 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::<T>().as_ptr(),
Expand All @@ -150,15 +150,15 @@ 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 {
unsafe { &*self.value }
}
}

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 }
}
Expand Down

0 comments on commit d021a3c

Please sign in to comment.