Add documentation to last_change_tick (#8598)

# Objective

This method has no documentation and it's extremely unclear what it
does, or what the returned tick represents.

## Solution

Write documentation.
This commit is contained in:
JoJoJet 2023-05-19 14:24:11 -04:00 committed by GitHub
parent c399755c74
commit b4e7f0899a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -1499,6 +1499,12 @@ impl World {
Tick::new(tick)
}
/// When called from within an exclusive system (a [`System`] that takes `&mut World` as its first
/// parameter), this method returns the [`Tick`] indicating the last time the exclusive system was run.
///
/// Otherwise, this returns the `Tick` indicating the last time that [`World::clear_trackers`] was called.
///
/// [`System`]: crate::system::System
#[inline]
pub fn last_change_tick(&self) -> Tick {
self.last_change_tick

View File

@ -237,11 +237,20 @@ impl<'w> UnsafeWorldCell<'w> {
unsafe { self.world_metadata() }.read_change_tick()
}
/// Returns the [`Tick`] indicating the last time that [`World::clear_trackers`] was called.
///
/// If this `UnsafeWorldCell` was created from inside of an exclusive system (a [`System`] that
/// takes `&mut World` as its first parameter), this will instead return the `Tick` indicating
/// the last time the system was run.
///
/// See [`World::last_change_tick()`].
///
/// [`System`]: crate::system::System
#[inline]
pub fn last_change_tick(self) -> Tick {
// SAFETY:
// - we only access world metadata
unsafe { self.world_metadata() }.last_change_tick
unsafe { self.world_metadata() }.last_change_tick()
}
#[inline]