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

[Merged by Bors] - Add assert_is_exclusive_system function #5275

Closed
Changes from 3 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
33 changes: 33 additions & 0 deletions crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,39 @@ pub fn assert_is_system<In, Out, Params, S: IntoSystem<In, Out, Params>>(sys: S)
}
}

/// Ensure that a given function is an exclusive system
///
/// This should be used when writing doc examples,
/// to confirm that systems used in an example are
/// valid exclusive systems
///
/// Passing assert
/// ```
/// # use bevy_ecs::prelude::World;
/// # use bevy_ecs::system::assert_is_exclusive_system;
/// fn an_exclusive_system(_world: &mut World) {}
///
/// assert_is_exclusive_system(an_exclusive_system);
/// ```
///
/// Failing assert
/// ```compile_fail
/// # use bevy_ecs::prelude::World;
/// # use bevy_ecs::system::assert_is_exclusive_system;
/// fn not_an_exclusive_system(_world: &mut World, number: f32) {}
///
/// assert_is_exclusive_system(not_an_exclusive_system);
/// ```
#[allow(unused_variables)]
MrPicklePinosaur marked this conversation as resolved.
Show resolved Hide resolved
pub fn assert_is_exclusive_system<
Params,
SystemType,
S: IntoExclusiveSystem<Params, SystemType>,
>(
sys: S,
) {
}

#[cfg(test)]
mod tests {
use std::any::TypeId;
Expand Down