Skip to content

Commit 0b5f7b4

Browse files
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.
1 parent fdf2ea7 commit 0b5f7b4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/bevy_ecs/src/archetype.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ pub(crate) enum ComponentStatus {
114114
}
115115

116116
pub(crate) struct AddBundle {
117+
/// The target archetype after the bundle is added to the source archetype
117118
pub archetype_id: ArchetypeId,
119+
/// For each component iterated in the same order as the source [`Bundle`](crate::bundle::Bundle),
120+
/// indicate if the component is newly added to the target archetype or if it already existed
118121
pub bundle_status: Vec<ComponentStatus>,
119122
}
120123

@@ -285,8 +288,12 @@ impl ArchetypeEntity {
285288
}
286289
}
287290

291+
/// Internal metadata for an [`Entity`] getting removed from an [`Archetype`].
288292
pub(crate) struct ArchetypeSwapRemoveResult {
293+
/// If the [`Entity`] was not the last in the [`Archetype`], it gets removed by swapping it out
294+
/// with the last entity in the archetype. In that case, this field contains the swapped entity.
289295
pub(crate) swapped_entity: Option<Entity>,
296+
/// The [`TableRow`] where the removed entity's components are stored.
290297
pub(crate) table_row: TableRow,
291298
}
292299

crates/bevy_ecs/src/world/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ impl World {
18361836
}
18371837

18381838
/// # Panics
1839-
/// panics if `component_id` is not registered in this world
1839+
/// Panics if `component_id` is not registered in this world
18401840
#[inline]
18411841
pub(crate) fn initialize_non_send_internal(
18421842
&mut self,

0 commit comments

Comments
 (0)