diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index e4d4b26d97de9..70fb139009fae 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -190,6 +190,10 @@ impl SparseSetIndex for EntityRow { /// Importantly, this can wrap, meaning each generation is not necessarily unique per [`EntityRow`]. /// /// This should be treated as a opaque identifier, and it's internal representation may be subject to change. +/// +/// Note that ordering doesn not necessarily represent which generation is earlier than another, as aliasing can prevent this. +/// Ordering should only be used to provide some form of determinism or algorithm. +/// It should not be used to check if a generation is younger than another. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Display)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] #[cfg_attr(feature = "bevy_reflect", reflect(opaque))] @@ -234,6 +238,14 @@ impl EntityGeneration { } } +impl Iterator for EntityGeneration { + type Item = Self; + + fn next(&mut self) -> Option { + Some(self.after_versions(1)) + } +} + /// Lightweight identifier of an [entity](crate::entity). /// /// The identifier is implemented using a [generational index]: a combination of an index and a generation.