-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify generics for the
SystemParamFunction
trait (#7675)
# Objective The `SystemParamFunction` (and `ExclusiveSystemParamFunction`) trait is very cumbersome to use, due to it requiring four generic type parameters. These are currently all used as marker parameters to satisfy rust's trait coherence rules. ### Example (before) ```rust pub fn pipe<AIn, Shared, BOut, A, AParam, AMarker, B, BParam, BMarker>( mut system_a: A, mut system_b: B, ) -> impl FnMut(In<AIn>, ParamSet<(AParam, BParam)>) -> BOut where A: SystemParamFunction<AIn, Shared, AParam, AMarker>, B: SystemParamFunction<Shared, BOut, BParam, BMarker>, AParam: SystemParam, BParam: SystemParam, ``` ## Solution Turn the `In`, `Out`, and `Param` generics into associated types. Merge the marker types together to retain coherence. ### Example (after) ```rust pub fn pipe<A, B, AMarker, BMarker>( mut system_a: A, mut system_b: B, ) -> impl FnMut(In<A::In>, ParamSet<(A::Param, B::Param)>) -> B::Out where A: SystemParamFunction<AMarker>, B: SystemParamFunction<BMarker, In = A::Out>, ``` --- ## Changelog + Simplified the `SystemParamFunction` and `ExclusiveSystemParamFunction` traits. ## Migration Guide For users of the `SystemParamFunction` trait, the generic type parameters `In`, `Out`, and `Param` have been turned into associated types. The same has been done with the `ExclusiveSystemParamFunction` trait.
- Loading branch information
Showing
3 changed files
with
84 additions
and
78 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
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
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