-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use type aliases for Query item types in Query and QueryState methods #4297
Use type aliases for Query item types in Query and QueryState methods #4297
Conversation
This is obviously not true given the type signature, contradicts the safety comment and it's not clear how it could be made true.
@@ -467,14 +467,12 @@ where | |||
/// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent | |||
/// iter() method, but cannot be chained like a normal [`Iterator`]. | |||
/// | |||
/// This can only be called for read-only queries. |
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.
This comment was blatantly false, and seems to just be a mistake. It contradicts the safety comment, and doesn't seem to make sense with the API.
Does rustdoc show the type aliases or do they get normalized? |
This was a serious barrier to productivity and correctness in #3333. |
Normalized, unfortunately: rust-lang/rust#15823 |
These lifetimes are still exposed and are still just as prone to soundness problems 🤷♀️ this seems like a nice win for readability but I don't think it really has anything to do with soundness or correctness of the ecs. |
Closing this out; not very useful until the rust bug is fixed. |
Objective
Query
andQueryState
methods have a large number of<<Q as WorldQuery>::ReadOnlyFetch as Fetch<'w, 's>>::Item
return typesSolution
QueryItem
type alias and a parallelReadOnlyQueryItem
alias to make this code easier to read and write.Future Work
I think we should consider refactoring
QueryIter
to have anItem
associated type and use these aliases there too. I'd prefer to keep this minimal though, so we can merge it ASAP and make #3333 easier.