Fix bad bounds for NonSend SystemParams (#2325)

# Objective

Currently, you can't call `is_added` or `is_changed` on a `NonSend` SystemParam, unless the Resource is a Component (implements `Send` and `Sync`). 
This defeats the purpose of providing change detection for NonSend Resources.
While fixing this, I also noticed that `NonSend` does not have a bound at all on its struct.

## Solution

Change the bounds of `T` to always be `'static`.
This commit is contained in:
MinerSebas 2021-06-09 19:01:59 +00:00
parent 19799b8d94
commit 63047b2417

View File

@ -683,7 +683,7 @@ impl<'a, T: Component> SystemParamFetch<'a> for RemovedComponentsState<T> {
/// # Panics
///
/// Panics when used as a `SystemParameter` if the resource does not exist.
pub struct NonSend<'w, T> {
pub struct NonSend<'w, T: 'static> {
pub(crate) value: &'w T,
ticks: ComponentTicks,
last_change_tick: u32,
@ -702,7 +702,7 @@ where
}
}
impl<'w, T: Component> NonSend<'w, T> {
impl<'w, T: 'static> NonSend<'w, T> {
/// Returns true if (and only if) this resource been added since the last execution of this
/// system.
pub fn is_added(&self) -> bool {