bevy/crates/bevy_ecs/src/system
Zachary Harrold 950bd2284d
System::type_id Consistency (#11728)
# Objective

- Fixes #11679

## Solution

- Added `IntoSystem::system_type_id` which returns the equivalent of
`system.into_system().type_id()` without construction. This allows for
getting the `TypeId` of functions (a function is an unnamed type and
therefore you cannot call `TypeId::of::<apply_deferred::System>()`)
- Added default implementation of `System::type_id` to ensure
consistency between implementations. Some returned `Self`, while others
were returning an inner value instead. This ensures consistency with
`IntoSystem::system_type_id`.

## Migration Guide

If you use `System::type_id()` on function systems (exclusive or not),
ensure you are comparing its value to other `System::type_id()` calls,
or `IntoSystem::system_type_id()`.

This code wont require any changes, because `IntoSystem`'s are directly
compared to each other.

```rust
fn test_system() {}

let type_id = test_system.type_id();

// ...

// No change required
assert_eq!(test_system.type_id(), type_id);
```

Likewise, this code wont, because `System`'s are directly compared.

```rust
fn test_system() {}

let type_id = IntoSystem::into_system(test_system).type_id();

// ...

// No change required
assert_eq!(IntoSystem::into_system(test_system).type_id(), type_id);
```

The below _does_ require a change, since you're comparing a `System`
type to a `IntoSystem` type.

```rust
fn test_system() {}

// Before
assert_eq!(test_system.type_id(), IntoSystem::into_system(test_system).type_id());

// After
assert_eq!(test_system.system_type_id(), IntoSystem::into_system(test_system).type_id());
```
2024-02-06 14:43:33 +00:00
..
commands Implement Debug for CommandQueue (#11444) 2024-01-22 15:45:17 +00:00
adapter_system.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00
combinator.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00
exclusive_function_system.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00
exclusive_system_param.rs impl ExclusiveSystemParam for PhantomData (#11153) 2024-01-01 16:02:21 +00:00
function_system.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00
mod.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00
query.rs Deprecated Various Component Methods from Query and QueryState (#9920) 2024-02-04 01:01:59 +00:00
system_name.rs impl ExclusiveSystemParam for SystemName (#11163) 2024-01-01 17:08:29 +00:00
system_param.rs refactor: Simplify lifetimes for Commands and related types (#11445) 2024-01-22 15:35:42 +00:00
system_registry.rs Exclusive systems can now be used for one-shot systems (#11560) 2024-01-27 16:10:39 +00:00
system.rs System::type_id Consistency (#11728) 2024-02-06 14:43:33 +00:00