diff --git a/src/query/result/archetype_identifiers.rs b/src/query/result/archetype_claims.rs similarity index 79% rename from src/query/result/archetype_identifiers.rs rename to src/query/result/archetype_claims.rs index 20b4b26e..4d6061da 100644 --- a/src/query/result/archetype_identifiers.rs +++ b/src/query/result/archetype_claims.rs @@ -1,3 +1,5 @@ +//! Iterator over dynamic claims of a query on its affected archetypes. + use crate::{ archetype, archetypes, @@ -16,7 +18,11 @@ use crate::{ }; use core::marker::PhantomData; -pub struct ArchetypeIdentifiers<'a, R, F, FI, V, VI, P, I, Q> +/// Iterator over dynamic claims of a query on its affected archetypes. +/// +/// This iterator returns key-value pairs of archetype identifiers and the list of claimed +/// components for the given query on that archetype. +pub struct ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> where R: Registry, { @@ -31,11 +37,13 @@ where reshape_indices: PhantomData, } -impl<'a, R, F, FI, V, VI, P, I, Q> ArchetypeIdentifiers<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, R, F, FI, V, VI, P, I, Q> ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> where R: Registry, { - /// # SAFETY + /// Returns a new `ArchetypeClaims` iterator. + /// + /// # Safety /// The `archetype::IdentifierRef`s over which this iterator iterates must not outlive the /// `Archetypes` to which they belong. pub(crate) unsafe fn new(archetypes_iter: archetypes::IterMut<'a, R>) -> Self { @@ -53,7 +61,7 @@ where } } -impl<'a, R, F, FI, V, VI, P, I, Q> Iterator for ArchetypeIdentifiers<'a, R, F, FI, V, VI, P, I, Q> +impl<'a, R, F, FI, V, VI, P, I, Q> Iterator for ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> where F: Filter, V: Views<'a> + Filter, diff --git a/src/query/result/mod.rs b/src/query/result/mod.rs index 0e4f17ad..5bd8bc7a 100644 --- a/src/query/result/mod.rs +++ b/src/query/result/mod.rs @@ -50,7 +50,7 @@ //! [`World`]: crate::world::World #[cfg(feature = "rayon")] -pub(crate) mod archetype_identifiers; +pub(crate) mod archetype_claims; pub(crate) mod get; pub(crate) mod reshape; @@ -64,7 +64,7 @@ pub use iter::Iter; pub use par_iter::ParIter; #[cfg(feature = "rayon")] -pub(crate) use archetype_identifiers::ArchetypeIdentifiers; +pub(crate) use archetype_claims::ArchetypeClaims; pub(crate) use get::Get; pub(crate) use reshape::Reshape; #[cfg(feature = "rayon")] diff --git a/src/system/schedule/stage.rs b/src/system/schedule/stage.rs index 7304bbf5..e7a4b5ed 100644 --- a/src/system/schedule/stage.rs +++ b/src/system/schedule/stage.rs @@ -125,7 +125,7 @@ where // SAFETY: The access to the world's archetype identifiers follows Rust's borrowing // rules. unsafe { - (*world.get()).query_archetype_identifiers(Query::::new()) + (*world.get()).query_archetype_claims(Query::::new()) } { match merged_borrowed_archetypes.entry(identifier) { @@ -157,7 +157,7 @@ fn query_archetype_identifiers_unchecked<'a, R, T, FI, VI, P, I, Q>( // SAFETY: The access to the world's archetype identifiers follows Rust's borrowing // rules. unsafe { - (*world.get()).query_archetype_identifiers(Query::::new()) + (*world.get()).query_archetype_claims(Query::::new()) } { borrowed_archetypes.insert_unique_unchecked(identifier, claims); diff --git a/src/world/mod.rs b/src/world/mod.rs index 0a482af1..9909e57f 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -360,22 +360,24 @@ where result::ParIter::new(self.archetypes.par_iter_mut()) } + /// Return the claims on each archetype touched by the given query. + /// /// # Safety /// The `archetype::IdentifierRef`s over which this iterator iterates must not outlive the /// `Archetypes` to which they belong. #[cfg(feature = "rayon")] #[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))] - pub(crate) unsafe fn query_archetype_identifiers<'a, V, F, VI, FI, P, I, Q>( + pub(crate) unsafe fn query_archetype_claims<'a, V, F, VI, FI, P, I, Q>( &'a mut self, #[allow(unused_variables)] query: Query, - ) -> result::ArchetypeIdentifiers<'a, R, F, FI, V, VI, P, I, Q> + ) -> result::ArchetypeClaims<'a, R, F, FI, V, VI, P, I, Q> where V: Views<'a> + Filter, F: Filter, R: ContainsFilter, And>, { // SAFETY: The safety contract here is upheld by the safety contract of this method. - unsafe { result::ArchetypeIdentifiers::new(self.archetypes.iter_mut()) } + unsafe { result::ArchetypeClaims::new(self.archetypes.iter_mut()) } } /// Run a [`System`] over the entities in this `World`.