bevy/crates/bevy_ecs/src
urben1680 76b8310da5
Replace (Partial)Ord for EntityGeneration with corrected standalone method (#19432)
# Objective

#19421 implemented `Ord` for `EntityGeneration` along the lines of [the
impl from
slotmap](https://docs.rs/slotmap/latest/src/slotmap/util.rs.html#8):
```rs
/// Returns if a is an older version than b, taking into account wrapping of
/// versions.
pub fn is_older_version(a: u32, b: u32) -> bool {
    let diff = a.wrapping_sub(b);
    diff >= (1 << 31)
}
```

But that PR and the slotmap impl are different:

**slotmap impl**
- if `(1u32 << 31)` is greater than `a.wrapping_sub(b)`, then `a` is
older than `b`
- if `(1u32 << 31)` is equal to `a.wrapping_sub(b)`, then `a` is older
than `b`
- if `(1u32 << 31)` is less than `a.wrapping_sub(b)`, then `a` is equal
or newer than `b`

**previous PR impl**
- if `(1u32 << 31)` is greater than `a.wrapping_sub(b)`, then `a` is
older than `b`
- if `(1u32 << 31)` is equal to `a.wrapping_sub(b)`, then `a` is equal
to `b` ⚠️
- if `(1u32 << 31)` is less than `a.wrapping_sub(b)`, then `a` is newer
than `b` ⚠️

This ordering is also not transitive, therefore it should not implement
`PartialOrd`.

## Solution

Fix the impl in a standalone method, remove the `Partialord`/`Ord`
implementation.

## Testing

Given the first impl was wrong and got past reviews, I think a new unit
test is justified.
2025-06-07 22:29:13 +00:00
..
entity Replace (Partial)Ord for EntityGeneration with corrected standalone method (#19432) 2025-06-07 22:29:13 +00:00
error More uninlined_format_args fixes (#19396) 2025-05-28 02:35:18 +00:00
event Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
observer Hot patching systems with subsecond (#19309) 2025-06-03 21:12:38 +00:00
query Remove ArchetypeComponentId and archetype_component_access (#19143) 2025-05-27 19:04:32 +00:00
reflect bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
relationship Simplified on_replace and on_despawn relationship hooks. (#19378) 2025-06-02 22:15:18 +00:00
schedule Hot patching systems with subsecond (#19309) 2025-06-03 21:12:38 +00:00
storage Remove invalid entity locations (#19433) 2025-05-31 16:34:33 +00:00
system bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
world Fix regression on the get/get_mut/get_not_found (#19505) 2025-06-06 21:04:27 +00:00
archetype.rs Trigger ArchetypeCreated event when new archetype is created (#19455) 2025-06-02 22:27:45 +00:00
batching.rs Nonmax all rows (#19132) 2025-05-26 17:39:55 +00:00
bundle.rs Trigger ArchetypeCreated event when new archetype is created (#19455) 2025-06-02 22:27:45 +00:00
change_detection.rs Fix EntityMeta.spawned_or_despawned unsoundness (#19350) 2025-05-27 22:45:07 +00:00
component.rs Only get valid component ids (#19510) 2025-06-06 20:59:57 +00:00
entity_disabling.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
hierarchy.rs bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
intern.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
label.rs Remove upcasting methods + Cleanup interned label code (#18984) 2025-05-26 15:38:12 +00:00
lib.rs bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
name.rs Make entity generation a new type and remove identifier (#19121) 2025-05-08 04:03:05 +00:00
never.rs Use never_say_never hack to work around Rust 2024 regression for fn traits (#18804) 2025-04-14 19:59:48 +00:00
removal_detection.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
resource.rs refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform (#19305) 2025-05-27 04:57:26 +00:00
spawn.rs Increase upper limit of children! (#18865) 2025-05-06 00:58:30 +00:00
traversal.rs Add missing words in Traversal doc comment (#19298) 2025-05-19 19:34:59 +00:00