Adding some docs for archetype internals (#12578)

# Objective


I was reading some of the Archetype and Bundle code and was getting
confused a little bit in some places (is the `archetype_id` in
`AddBundle` the source or the target archetype id?).
Small PR that adds some docstrings to make it easier for first-time
readers.
This commit is contained in:
Charles Bournhonesque 2024-03-22 21:48:31 -04:00 committed by GitHub
parent fdf2ea7cc5
commit 0b5f7b4ff2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -114,7 +114,10 @@ pub(crate) enum ComponentStatus {
}
pub(crate) struct AddBundle {
/// The target archetype after the bundle is added to the source archetype
pub archetype_id: ArchetypeId,
/// For each component iterated in the same order as the source [`Bundle`](crate::bundle::Bundle),
/// indicate if the component is newly added to the target archetype or if it already existed
pub bundle_status: Vec<ComponentStatus>,
}
@ -285,8 +288,12 @@ impl ArchetypeEntity {
}
}
/// Internal metadata for an [`Entity`] getting removed from an [`Archetype`].
pub(crate) struct ArchetypeSwapRemoveResult {
/// If the [`Entity`] was not the last in the [`Archetype`], it gets removed by swapping it out
/// with the last entity in the archetype. In that case, this field contains the swapped entity.
pub(crate) swapped_entity: Option<Entity>,
/// The [`TableRow`] where the removed entity's components are stored.
pub(crate) table_row: TableRow,
}

View File

@ -1836,7 +1836,7 @@ impl World {
}
/// # Panics
/// panics if `component_id` is not registered in this world
/// Panics if `component_id` is not registered in this world
#[inline]
pub(crate) fn initialize_non_send_internal(
&mut self,