From 07170a7e86adbb55c370d562cb5a93688f692745 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sun, 10 Jul 2022 18:47:52 -0400 Subject: [PATCH 1/6] Add `assert_is_exclusive_system` function --- crates/bevy_ecs/src/system/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 04d14f9afe652..b3a2a864e73f3 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -96,6 +96,17 @@ pub fn assert_is_system>(sys: S) } } +/// Ensure that a given function is an exclusive system +#[allow(unused_variables)] +pub fn assert_is_exclusive_system< + Params, + SystemType, + S: IntoExclusiveSystem, +>( + sys: S, +) { +} + #[cfg(test)] mod tests { use std::any::TypeId; From 5bcdee5615ddce3090a7a44f9a6b23afe77167a2 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sun, 10 Jul 2022 19:18:12 -0400 Subject: [PATCH 2/6] add doc test --- crates/bevy_ecs/src/system/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index b3a2a864e73f3..596c2ac1041b6 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -97,6 +97,30 @@ pub fn assert_is_system>(sys: S) } /// Ensure that a given function is an exclusive system +/// +/// This should be used when writing doc examples, +/// to confirm that systems used in an example are +/// valid exclusive systems +/// +/// passing assert +/// ``` +/// # use bevy_ecs::prelude::World; +/// # use bevy_ecs::system::assert_is_exclusive_system; +/// +/// fn an_exclusive_system(_world: &mut World) {} +/// +/// assert_is_exclusive_system(an_exclusive_system); +/// ``` +/// +/// failing assert +/// ```compile_fail +/// # use bevy_ecs::prelude::World; +/// # use bevy_ecs::system::assert_is_exclusive_system; +/// +/// fn not_an_exclusive_system(_world: &mut World, number: f32) {} +/// +/// assert_is_exclusive_system(not_an_exclusive_system); +/// ``` #[allow(unused_variables)] pub fn assert_is_exclusive_system< Params, From 0b7afa049983c94451277881fb156d639aab8bd3 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sun, 10 Jul 2022 19:26:19 -0400 Subject: [PATCH 3/6] formatting fix --- crates/bevy_ecs/src/system/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 596c2ac1041b6..0eb0cf0282dc8 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -102,21 +102,19 @@ pub fn assert_is_system>(sys: S) /// to confirm that systems used in an example are /// valid exclusive systems /// -/// passing assert +/// Passing assert /// ``` /// # use bevy_ecs::prelude::World; /// # use bevy_ecs::system::assert_is_exclusive_system; -/// /// fn an_exclusive_system(_world: &mut World) {} /// /// assert_is_exclusive_system(an_exclusive_system); /// ``` /// -/// failing assert +/// Failing assert /// ```compile_fail /// # use bevy_ecs::prelude::World; /// # use bevy_ecs::system::assert_is_exclusive_system; -/// /// fn not_an_exclusive_system(_world: &mut World, number: f32) {} /// /// assert_is_exclusive_system(not_an_exclusive_system); From 9df5ce8da4efbfec1f0aafa5420781f31c5bb35b Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Mon, 11 Jul 2022 12:09:43 -0400 Subject: [PATCH 4/6] refactor --- crates/bevy_ecs/src/system/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 0eb0cf0282dc8..bedea3fd0b625 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -119,13 +119,12 @@ pub fn assert_is_system>(sys: S) /// /// assert_is_exclusive_system(not_an_exclusive_system); /// ``` -#[allow(unused_variables)] pub fn assert_is_exclusive_system< Params, SystemType, S: IntoExclusiveSystem, >( - sys: S, + _sys: S, ) { } From 1d5bc91791a605322d8cb328b7679c87cc03a2d1 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 13 Jul 2022 17:01:17 -0400 Subject: [PATCH 5/6] Update crates/bevy_ecs/src/system/mod.rs Co-authored-by: ira --- crates/bevy_ecs/src/system/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index bedea3fd0b625..237649a1ebb82 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -122,9 +122,8 @@ pub fn assert_is_system>(sys: S) pub fn assert_is_exclusive_system< Params, SystemType, - S: IntoExclusiveSystem, >( - _sys: S, + _sys: impl IntoExclusiveSystem, ) { } From 0698fee210c0dff9d74ecc85a67588dada5890e0 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 13 Jul 2022 17:03:19 -0400 Subject: [PATCH 6/6] format --- crates/bevy_ecs/src/system/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 237649a1ebb82..234000ef855d8 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -119,10 +119,7 @@ pub fn assert_is_system>(sys: S) /// /// assert_is_exclusive_system(not_an_exclusive_system); /// ``` -pub fn assert_is_exclusive_system< - Params, - SystemType, ->( +pub fn assert_is_exclusive_system( _sys: impl IntoExclusiveSystem, ) { }