Skip to content

Commit c602752

Browse files
committed
Example for ComponentIdFor
1 parent d19a4bb commit c602752

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

crates/bevy_ecs/src/component.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,17 @@ impl ComponentTicks {
674674
}
675675
}
676676

677-
/// Initialize and fetch a component id for a generic type.
677+
/// Initialize and fetch a [`ComponentId`] for a specific type.
678+
///
679+
/// # Example
680+
/// ```rust
681+
/// # use bevy_ecs::{system::Local, component::{Component, ComponentIdFor}};
682+
/// #[derive(Component)]
683+
/// struct Player;
684+
/// fn my_system(my_component_id: Local<ComponentIdFor<Player>>) {
685+
/// // ...
686+
/// }
687+
/// ```
678688
pub struct ComponentIdFor<T: Component> {
679689
component_id: ComponentId,
680690
phantom: PhantomData<T>,

crates/bevy_ecs/src/removal_detection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ impl RemovedComponentEvents {
7474
}
7575
}
7676

77-
#[derive(SystemParam)]
7877
/// A [`SystemParam`] that grants access to the entities that had their `T` [`Component`] removed.
7978
///
8079
/// Note that this does not allow you to see which data existed before removal.
@@ -106,6 +105,7 @@ impl RemovedComponentEvents {
106105
/// }
107106
/// # bevy_ecs::system::assert_is_system(react_on_removal);
108107
/// ```
108+
#[derive(SystemParam)]
109109
pub struct RemovedComponents<'w, 's, T: Component> {
110110
component_id: Local<'s, ComponentIdFor<T>>,
111111
reader: Local<'s, RemovedComponentReader<T>>,

0 commit comments

Comments
 (0)