Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - change is_system_type() -> bool to system_type() -> Option<TypeId> #7715

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions crates/bevy_ecs/macros/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ pub fn derive_set(input: syn::DeriveInput, trait_path: &syn::Path) -> TokenStrea

(quote! {
impl #impl_generics #trait_path for #ident #ty_generics #where_clause {
fn is_system_type(&self) -> bool {
false
}

fn is_base(&self) -> bool {
#is_base
}
Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_ecs/src/schedule/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl SystemSetConfig {
// system type sets are automatically populated
// to avoid unintentionally broad changes, they cannot be configured
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"configuring system type sets is not allowed"
);

Expand Down Expand Up @@ -200,7 +200,7 @@ impl IntoSystemSetConfig for SystemSetConfig {
#[track_caller]
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"adding arbitrary systems to a system type set is not allowed"
);
assert!(
Expand All @@ -218,7 +218,7 @@ impl IntoSystemSetConfig for SystemSetConfig {
#[track_caller]
fn in_base_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"System type sets cannot be base sets."
);
assert!(
Expand Down Expand Up @@ -394,7 +394,7 @@ impl IntoSystemConfig<()> for SystemConfig {
#[track_caller]
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"adding arbitrary systems to a system type set is not allowed"
);
assert!(
Expand All @@ -408,7 +408,7 @@ impl IntoSystemConfig<()> for SystemConfig {
#[track_caller]
fn in_base_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"System type sets cannot be base sets."
);
assert!(
Expand Down Expand Up @@ -548,7 +548,7 @@ impl IntoSystemConfigs<()> for SystemConfigs {
#[track_caller]
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"adding arbitrary systems to a system type set is not allowed"
);
assert!(
Expand All @@ -565,7 +565,7 @@ impl IntoSystemConfigs<()> for SystemConfigs {
#[track_caller]
fn in_base_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"System type sets cannot be base sets."
);
assert!(
Expand Down Expand Up @@ -692,7 +692,7 @@ impl IntoSystemSetConfigs for SystemSetConfigs {
#[track_caller]
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"adding arbitrary systems to a system type set is not allowed"
);
assert!(
Expand All @@ -713,7 +713,7 @@ impl IntoSystemSetConfigs for SystemSetConfigs {
#[track_caller]
fn in_base_set(mut self, set: impl SystemSet) -> Self {
assert!(
!set.is_system_type(),
set.system_type().is_none(),
"System type sets cannot be base sets."
);
assert!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl SystemSetNode {
}

pub fn is_system_type(&self) -> bool {
self.inner.is_system_type()
self.inner.system_type().is_some()
}
}

Expand Down
11 changes: 6 additions & 5 deletions crates/bevy_ecs/src/schedule/set.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::any::TypeId;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
Expand All @@ -17,9 +18,9 @@ pub type BoxedScheduleLabel = Box<dyn ScheduleLabel>;

/// Types that identify logical groups of systems.
pub trait SystemSet: DynHash + Debug + Send + Sync + 'static {
/// Returns `true` if this system set is a [`SystemTypeSet`].
fn is_system_type(&self) -> bool {
false
/// Returns `Some` if this system set is a [`SystemTypeSet`].
fn system_type(&self) -> Option<TypeId> {
None
}

/// Returns `true` if this set is a "base system set". Systems
Expand Down Expand Up @@ -102,8 +103,8 @@ impl<T> PartialEq for SystemTypeSet<T> {
impl<T> Eq for SystemTypeSet<T> {}

impl<T> SystemSet for SystemTypeSet<T> {
fn is_system_type(&self) -> bool {
true
fn system_type(&self) -> Option<TypeId> {
Some(TypeId::of::<T>())
}

fn dyn_clone(&self) -> Box<dyn SystemSet> {
Expand Down