Skip to content

Commit 4bcb310

Browse files
Basic EntityRef and EntityMut docs (#3388)
# Objective - `EntityRef` and `EntityMut` are surpisingly important public types when working directly with the `World`. - They're undocumented. ## Solution - Just add docs!
1 parent 5155034 commit 4bcb310

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/bevy_ecs/src/world/entity_ref.rs

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
};
1010
use std::any::TypeId;
1111

12+
/// A read-only reference to a particular [`Entity`] and all of its components
1213
pub struct EntityRef<'w> {
1314
world: &'w World,
1415
entity: Entity,
@@ -98,6 +99,7 @@ impl<'w> EntityRef<'w> {
9899
}
99100
}
100101

102+
/// A mutable reference to a particular [`Entity`] and all of its components
101103
pub struct EntityMut<'w> {
102104
world: &'w mut World,
103105
entity: Entity,
@@ -464,6 +466,8 @@ impl<'w> EntityMut<'w> {
464466
}
465467

466468
// TODO: move to Storages?
469+
/// Get a raw pointer to a particular [`Component`] on a particular [`Entity`] in the provided [`World`].
470+
///
467471
/// # Safety
468472
/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside
469473
/// the archetype
@@ -494,6 +498,8 @@ unsafe fn get_component(
494498
}
495499

496500
// TODO: move to Storages?
501+
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] on a particular [`Entity`] in the provided [World].
502+
///
497503
/// # Safety
498504
/// Caller must ensure that `component_id` is valid
499505
#[inline]
@@ -566,6 +572,8 @@ unsafe fn take_component(
566572
}
567573
}
568574

575+
/// Get a raw pointer to a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
576+
///
569577
/// # Safety
570578
/// `entity_location` must be within bounds of an archetype that exists.
571579
unsafe fn get_component_with_type(
@@ -578,6 +586,8 @@ unsafe fn get_component_with_type(
578586
get_component(world, component_id, entity, location)
579587
}
580588

589+
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
590+
///
581591
/// # Safety
582592
/// `entity_location` must be within bounds of an archetype that exists.
583593
pub(crate) unsafe fn get_component_and_ticks_with_type(

0 commit comments

Comments
 (0)