From 922b1bd8fffb96c635f1e302190a548dc33e6f16 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:48:38 -0500 Subject: [PATCH 1/5] add a const constructor to `Access` --- crates/bevy_ecs/src/query/access.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index a28e6df23ef83..e319349e48c03 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -71,16 +71,20 @@ impl fmt::Debug for Access { } impl Default for Access { fn default() -> Self { + Self::new() + } +} + +impl Access { + pub const fn new() -> Self { Self { reads_all: false, - reads_and_writes: Default::default(), - writes: Default::default(), + reads_and_writes: FixedBitSet::new(), + writes: FixedBitSet::new(), marker: PhantomData, } } -} -impl Access { /// Increases the set capacity to the specified amount. /// /// Does nothing if `capacity` is less than or equal to the current value. From 7083845f8e02e93d73987a13fa2ef39e3df2eb72 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:48:54 -0500 Subject: [PATCH 2/5] add a const constructor to `PipeSystem` --- crates/bevy_ecs/src/system/system_piping.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_ecs/src/system/system_piping.rs b/crates/bevy_ecs/src/system/system_piping.rs index d28158b697836..1541ecf0abcde 100644 --- a/crates/bevy_ecs/src/system/system_piping.rs +++ b/crates/bevy_ecs/src/system/system_piping.rs @@ -54,6 +54,18 @@ pub struct PipeSystem { archetype_component_access: Access, } +impl PipeSystem { + pub const fn new(system_a: SystemA, system_b: SystemB, name: Cow<'static, str>) -> Self { + Self { + system_a, + system_b, + name, + component_access: Access::new(), + archetype_component_access: Access::new(), + } + } +} + impl> System for PipeSystem { type In = SystemA::In; type Out = SystemB::Out; From e76333343c0308f51acf8c150f578f7fce8ebabe Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:51:32 -0500 Subject: [PATCH 3/5] use `PipeSystem::new` internally --- crates/bevy_ecs/src/system/system_piping.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/bevy_ecs/src/system/system_piping.rs b/crates/bevy_ecs/src/system/system_piping.rs index 1541ecf0abcde..b18e82cc7f8c6 100644 --- a/crates/bevy_ecs/src/system/system_piping.rs +++ b/crates/bevy_ecs/src/system/system_piping.rs @@ -166,13 +166,8 @@ where fn pipe(self, system: SystemB) -> PipeSystem { let system_a = IntoSystem::into_system(self); let system_b = IntoSystem::into_system(system); - PipeSystem { - name: Cow::Owned(format!("Pipe({}, {})", system_a.name(), system_b.name())), - system_a, - system_b, - archetype_component_access: Default::default(), - component_access: Default::default(), - } + let name = format!("Pipe({}, {})", system_a.name(), system_b.name()); + PipeSystem::new(system_a, system_b, Cow::Owned(name)) } } From acc576b38a8cecbe80c161e212453619d8ab8dba Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:53:38 -0500 Subject: [PATCH 4/5] document `Access::new` --- crates/bevy_ecs/src/query/access.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index e319349e48c03..ea18adf841073 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -76,6 +76,7 @@ impl Default for Access { } impl Access { + /// Creates an empty [`Access`] collection. pub const fn new() -> Self { Self { reads_all: false, From ebba24478166548367f426c4f257ee0c35e203d6 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:55:16 -0500 Subject: [PATCH 5/5] document `PipeSystem::new` --- crates/bevy_ecs/src/system/system_piping.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bevy_ecs/src/system/system_piping.rs b/crates/bevy_ecs/src/system/system_piping.rs index b18e82cc7f8c6..dd343461b9e5f 100644 --- a/crates/bevy_ecs/src/system/system_piping.rs +++ b/crates/bevy_ecs/src/system/system_piping.rs @@ -55,6 +55,9 @@ pub struct PipeSystem { } impl PipeSystem { + /// Manual constructor for creating a [`PipeSystem`]. + /// This should only be used when [`IntoPipeSystem::pipe`] cannot be used, + /// such as in `const` contexts. pub const fn new(system_a: SystemA, system_b: SystemB, name: Cow<'static, str>) -> Self { Self { system_a,