mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
Add assert_is_exclusive_system
function (#5275)
Add compile time check for if a system is an exclusive system. Resolves #4788 Co-authored-by: Daniel Liu <mr.picklepinosaur@gmail.com> Co-authored-by: Daniel Liu <danieliu3120@gmail.com>
This commit is contained in:
parent
b3d15153f3
commit
fe59fe5860
1 changed files with 28 additions and 0 deletions
|
@ -96,6 +96,34 @@ 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);
|
||||
/// ```
|
||||
pub fn assert_is_exclusive_system<Params, SystemType>(
|
||||
_sys: impl IntoExclusiveSystem<Params, SystemType>,
|
||||
) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::any::TypeId;
|
||||
|
|
Loading…
Reference in a new issue