Skip to content
Closed
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
12 changes: 12 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -234,6 +238,14 @@ impl EntityGeneration {
}
}

impl Iterator for EntityGeneration {
type Item = Self;

fn next(&mut self) -> Option<Self::Item> {
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.
Expand Down