Skip to content

Commit 1623043

Browse files
committed
fix errors
1 parent 981b206 commit 1623043

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,15 +794,12 @@ impl<'w, 's> Commands<'w, 's> {
794794
/// [`CachedSystemId`](crate::system::CachedSystemId) resource.
795795
///
796796
/// See [`World::register_system_cached`] for more information.
797-
pub fn run_system_cached_with<
798-
I: 'static + Send,
797+
pub fn run_system_cached_with<I, M, S>(&mut self, system: S, input: I::Inner<'static>)
798+
where
799+
I: SystemInput<Inner<'static>: Send> + Send + 'static,
799800
M: 'static,
800801
S: IntoSystem<I, (), M> + 'static,
801-
>(
802-
&mut self,
803-
system: S,
804-
input: I,
805-
) {
802+
{
806803
self.queue(RunSystemCachedWith::new(system, input));
807804
}
808805

crates/bevy_ecs/src/system/system_registry.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::bundle::Bundle;
22
use crate::change_detection::Mut;
33
use crate::entity::Entity;
44
use crate::system::input::SystemInput;
5-
use crate::system::{BoxedSystem, IntoSystem, System};
5+
use crate::system::{BoxedSystem, IntoSystem, System, SystemIn};
66
use crate::world::{Command, World};
77
use crate::{self as bevy_ecs};
88
use bevy_ecs_macros::{Component, Resource};
@@ -365,10 +365,12 @@ impl World {
365365
/// If you want to access values from the environment within a system, consider passing them in
366366
/// as inputs via [`World::run_system_cached_with`]. If that's not an option, consider
367367
/// [`World::register_system`] instead.
368-
pub fn register_system_cached<I: 'static, O: 'static, M, S: IntoSystem<I, O, M> + 'static>(
369-
&mut self,
370-
system: S,
371-
) -> SystemId<I, O> {
368+
pub fn register_system_cached<I, O, M, S>(&mut self, system: S) -> SystemId<I, O>
369+
where
370+
I: SystemInput + 'static,
371+
O: 'static,
372+
S: IntoSystem<I, O, M> + 'static,
373+
{
372374
const {
373375
assert!(
374376
size_of::<S>() == 0,
@@ -397,10 +399,15 @@ impl World {
397399
/// Removes a cached system and its [`CachedSystemId`] resource.
398400
///
399401
/// See [`World::register_system_cached`] for more information.
400-
pub fn remove_system_cached<I: 'static, O: 'static, M, S: IntoSystem<I, O, M> + 'static>(
402+
pub fn remove_system_cached<I, O, M, S>(
401403
&mut self,
402404
_system: S,
403-
) -> Result<RemovedSystem<I, O>, RegisteredSystemError<I, O>> {
405+
) -> Result<RemovedSystem<I, O>, RegisteredSystemError<I, O>>
406+
where
407+
I: SystemInput + 'static,
408+
O: 'static,
409+
S: IntoSystem<I, O, M> + 'static,
410+
{
404411
let id = self
405412
.remove_resource::<CachedSystemId<S::System>>()
406413
.ok_or(RegisteredSystemError::SystemNotCached)?;
@@ -420,11 +427,16 @@ impl World {
420427
/// Runs a cached system with an input, registering it if necessary.
421428
///
422429
/// See [`World::register_system_cached`] for more information.
423-
pub fn run_system_cached_with<I: 'static, O: 'static, M, S: IntoSystem<I, O, M> + 'static>(
430+
pub fn run_system_cached_with<I, O, M, S>(
424431
&mut self,
425432
system: S,
426-
input: I,
427-
) -> Result<O, RegisteredSystemError<I, O>> {
433+
input: I::Inner<'_>,
434+
) -> Result<O, RegisteredSystemError<I, O>>
435+
where
436+
I: SystemInput + 'static,
437+
O: 'static,
438+
S: IntoSystem<I, O, M> + 'static,
439+
{
428440
let id = self.register_system_cached(system);
429441
self.run_system_with_input(id, input)
430442
}
@@ -525,13 +537,16 @@ where
525537
/// See [`World::register_system_cached`] for more information.
526538
pub struct RunSystemCachedWith<S: System<Out = ()>> {
527539
system: S,
528-
input: S::In,
540+
input: SystemIn<'static, S>,
529541
}
530542

531543
impl<S: System<Out = ()>> RunSystemCachedWith<S> {
532544
/// Creates a new [`Command`] struct, which can be added to
533545
/// [`Commands`](crate::system::Commands).
534-
pub fn new<M>(system: impl IntoSystem<S::In, (), M, System = S>, input: S::In) -> Self {
546+
pub fn new<M>(
547+
system: impl IntoSystem<S::In, (), M, System = S>,
548+
input: SystemIn<'static, S>,
549+
) -> Self {
535550
Self {
536551
system: IntoSystem::into_system(system),
537552
input,
@@ -541,7 +556,7 @@ impl<S: System<Out = ()>> RunSystemCachedWith<S> {
541556

542557
impl<S: System<Out = ()>> Command for RunSystemCachedWith<S>
543558
where
544-
S::In: Send,
559+
S::In: SystemInput<Inner<'static>: Send>,
545560
{
546561
fn apply(self, world: &mut World) {
547562
let _ = world.run_system_cached_with(self.system, self.input);

0 commit comments

Comments
 (0)