Skip to content

Commit

Permalink
Weaken Local trait bound to Send + Sync + 'static
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile committed Jun 13, 2022
1 parent 8c3fcc3 commit cc0b179
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,12 @@ impl<'w, 's> SystemParamFetch<'w, 's> for WorldState {
/// // .add_system(reset_to_system(my_config))
/// # assert_is_system(reset_to_system(Config(10)));
/// ```
pub struct Local<'a, T: Resource>(&'a mut T);
pub struct Local<'a, T: Send + Sync + 'static>(&'a mut T);

// SAFE: Local only accesses internal state
unsafe impl<T: Resource> ReadOnlySystemParamFetch for LocalState<T> {}
// SAFE: Local only accesses internal state, and a system cannot be run twice simultaneously
unsafe impl<T: Send + Sync + 'static> ReadOnlySystemParamFetch for LocalState<T> {}

impl<'a, T: Resource> Debug for Local<'a, T>
impl<'a, T: Send + Sync + 'static> Debug for Local<'a, T>
where
T: Debug,
{
Expand All @@ -660,7 +660,7 @@ where
}
}

impl<'a, T: Resource> Deref for Local<'a, T> {
impl<'a, T: Send + Sync + 'static> Deref for Local<'a, T> {
type Target = T;

#[inline]
Expand All @@ -669,7 +669,7 @@ impl<'a, T: Resource> Deref for Local<'a, T> {
}
}

impl<'a, T: Resource> DerefMut for Local<'a, T> {
impl<'a, T: Send + Sync + 'static> DerefMut for Local<'a, T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
self.0
Expand All @@ -678,20 +678,20 @@ impl<'a, T: Resource> DerefMut for Local<'a, T> {

/// The [`SystemParamState`] of [`Local<T>`].
#[doc(hidden)]
pub struct LocalState<T: Resource>(T);
pub struct LocalState<T: Send + Sync + 'static>(T);

impl<'a, T: Resource + FromWorld> SystemParam for Local<'a, T> {
impl<'a, T: Send + Sync + 'static + FromWorld> SystemParam for Local<'a, T> {
type Fetch = LocalState<T>;
}

// SAFE: only local state is accessed
unsafe impl<T: Resource + FromWorld> SystemParamState for LocalState<T> {
unsafe impl<T: Send + Sync + 'static + FromWorld> SystemParamState for LocalState<T> {
fn init(world: &mut World, _system_meta: &mut SystemMeta) -> Self {
Self(T::from_world(world))
}
}

impl<'w, 's, T: Resource + FromWorld> SystemParamFetch<'w, 's> for LocalState<T> {
impl<'w, 's, T: Send + Sync + 'static + FromWorld> SystemParamFetch<'w, 's> for LocalState<T> {
type Item = Local<'s, T>;

#[inline]
Expand Down

0 comments on commit cc0b179

Please sign in to comment.