Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better doc for SystemName #11084

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,32 @@ unsafe impl SystemParam for SystemChangeTick {
}
}

/// Name of the system that corresponds to this [`crate::system::SystemState`].
/// [`SystemParam`] that returns the name of the system which it is used in.
///
/// This is not a reliable identifier, it is more so useful for debugging
/// purposes of finding where a system parameter is being used incorrectly.
/// This is not a reliable identifier, it is more so useful for debugging or logging.
///
/// # Examples
///
/// ```
/// # use bevy_ecs::system::SystemName;
/// # use bevy_ecs::system::SystemParam;
///
/// #[derive(SystemParam)]
/// struct Logger<'s> {
/// system_name: SystemName<'s>,
/// }
///
/// impl<'s> Logger<'s> {
/// fn log(&mut self, message: &str) {
/// eprintln!("{}: {}", self.system_name, message);
/// }
/// }
///
/// fn system1(mut logger: Logger) {
/// // Prints: "crate_name::mod_name::system1: Hello".
/// logger.log("Hello");
/// }
/// ```
#[derive(Debug)]
pub struct SystemName<'s>(&'s str);

Expand Down