add must_use to register_component_hooks (#19945)

# Objective

- I accidentally left a `register_component_hooks` without actually
adding a hook and didnt notice

## Solution

- mark it must_use so it doesnt happen to other people (maybe this is
just skill issue on me though)
This commit is contained in:
atlv 2025-07-04 12:24:46 -04:00 committed by GitHub
parent 58feca9b32
commit 1380a3b7f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -304,6 +304,7 @@ impl World {
/// Returns a mutable reference to the [`ComponentHooks`] for a [`Component`] type.
///
/// Will panic if `T` exists in any archetypes.
#[must_use]
pub fn register_component_hooks<T: Component>(&mut self) -> &mut ComponentHooks {
let index = self.register_component::<T>();
assert!(!self.archetypes.archetypes.iter().any(|a| a.contains(index)), "Components hooks cannot be modified if the component already exists in an archetype, use register_component if {} may already be in use", core::any::type_name::<T>());