Skip to content

Commit

Permalink
Add assert_is_exclusive_system function (bevyengine#5275)
Browse files Browse the repository at this point in the history
Add compile time check for if a system is an exclusive system. Resolves bevyengine#4788 

Co-authored-by: Daniel Liu <mr.picklepinosaur@gmail.com>
Co-authored-by: Daniel Liu <danieliu3120@gmail.com>
  • Loading branch information
3 people authored and inodentry committed Aug 8, 2022
1 parent 7cf232b commit 3c05b7f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 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,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;
Expand Down

0 comments on commit 3c05b7f

Please sign in to comment.