-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
SystemInput
tuples up to 8 elements (#16814)
# Objective - Writing an API, and I want to allow users to pass in extra data alongside the API provided input, and tuples are the most natural extension in this case. - Bring `SystemInput` up to par with `SystemParam` for tuple support. ## Solution - Added impls for tuples up to 8 elements. If you need a 9-arity tuple or more, write your own `SystemInput` type (it's incredibly simple to do). ## Testing - Added a test demonstrating this. --- ## Showcase Tuples of arbitrary`SystemInput`s are now supported: ```rust fn by_value((In(a), In(b)): (In<usize>, In<usize>)) -> usize { a + b } fn by_mut((InMut(a), In(b)): (InMut<usize>, In<usize>)) { *a += b; } let mut world = World::new(); let mut by_value = IntoSystem::into_system(by_value); let mut by_mut = IntoSystem::into_system(by_mut); by_value.initialize(&mut world); by_mut.initialize(&mut world); assert_eq!(by_value.run((12, 24), &mut world), 36); let mut a = 10; let b = 5; by_mut.run((&mut a, b), &mut world); assert_eq!(*a, 15); ```
- Loading branch information
Showing
1 changed file
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters