-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
documented run_system_cached issue#21617 #21707
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -500,6 +500,16 @@ impl World { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /// Runs a cached system, registering it if necessary. | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// # Type Inference Note | ||||||||||||||||||||||||||
| /// If the system returns `()`, you may need to explicitly constrain the output | ||||||||||||||||||||||||||
| /// type for error handling: | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// ```rust | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to declare
Suggested change
And you'll also need |
||||||||||||||||||||||||||
| /// () = world.run_system_cached(my_system)?; | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also recommend using a turbofish, both here and below. It is more verbose, but it's idiomatic rust, while
Suggested change
|
||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And since you're using
Suggested change
|
||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// Without this, Rust may fail to infer the system’s output type and produce | ||||||||||||||||||||||||||
| /// a `IntoResult<!>` inference error. | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, I thought the error was "cannot infer type of the type parameter ... Oh, I see, Anyway, it might be helpful to give a little more detail on the inference error, like:
Suggested change
|
||||||||||||||||||||||||||
| /// See [`World::register_system_cached`] for more information. | ||||||||||||||||||||||||||
| pub fn run_system_cached<O: 'static, M, S: IntoSystem<(), O, M> + 'static>( | ||||||||||||||||||||||||||
| &mut self, | ||||||||||||||||||||||||||
|
|
@@ -508,8 +518,21 @@ impl World { | |||||||||||||||||||||||||
| self.run_system_cached_with(system, ()) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /// Runs a cached system with an input, registering it if necessary. | ||||||||||||||||||||||||||
| /// Runs a cached system with the provided input, registering it if necessary. | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// This is a more general version of [`World::run_system_cached`], allowing | ||||||||||||||||||||||||||
| /// callers to supply an explicit system input. | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// # Type Inference Note | ||||||||||||||||||||||||||
| /// If the system returns `()`, you may need to explicitly constrain the | ||||||||||||||||||||||||||
| /// output type for proper error inference: | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// ```rust | ||||||||||||||||||||||||||
| /// () = world.run_system_cached_with(my_system, input)?; | ||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// Without this, Rust may fail to infer the system’s output type and produce | ||||||||||||||||||||||||||
| /// a `IntoResult<!>` inference error. | ||||||||||||||||||||||||||
| /// See [`World::register_system_cached`] for more information. | ||||||||||||||||||||||||||
| pub fn run_system_cached_with<I, O, M, S>( | ||||||||||||||||||||||||||
| &mut self, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think inference actually works for system functions that return plain
(), and we only get errors for systems that returnResult.