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!
This commit is contained in:
Alice Cecile 2022-04-25 14:32:57 +00:00
parent 5155034a58
commit 4bcb310008

View file

@ -9,6 +9,7 @@ use crate::{
};
use std::any::TypeId;
/// A read-only reference to a particular [`Entity`] and all of its components
pub struct EntityRef<'w> {
world: &'w World,
entity: Entity,
@ -98,6 +99,7 @@ impl<'w> EntityRef<'w> {
}
}
/// A mutable reference to a particular [`Entity`] and all of its components
pub struct EntityMut<'w> {
world: &'w mut World,
entity: Entity,
@ -464,6 +466,8 @@ impl<'w> EntityMut<'w> {
}
// TODO: move to Storages?
/// Get a raw pointer to a particular [`Component`] on a particular [`Entity`] in the provided [`World`].
///
/// # Safety
/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside
/// the archetype
@ -494,6 +498,8 @@ unsafe fn get_component(
}
// TODO: move to Storages?
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] on a particular [`Entity`] in the provided [World].
///
/// # Safety
/// Caller must ensure that `component_id` is valid
#[inline]
@ -566,6 +572,8 @@ unsafe fn take_component(
}
}
/// Get a raw pointer to a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
///
/// # Safety
/// `entity_location` must be within bounds of an archetype that exists.
unsafe fn get_component_with_type(
@ -578,6 +586,8 @@ unsafe fn get_component_with_type(
get_component(world, component_id, entity, location)
}
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
///
/// # Safety
/// `entity_location` must be within bounds of an archetype that exists.
pub(crate) unsafe fn get_component_and_ticks_with_type(