Replies: 1 comment 3 replies
-
That lifetime is what makes this api safe. If we don't tie the iterator lifetime to Query, then people could call |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone!
I've been playing around with a prototype of query Views. The idea of "query views" pretty much boils down to being able to map queries to "sub-queries".
Assuming, we've got a query
Query<(&ComponentA, &ComponentB, &ComponentC)>
, we could do the following:This is the only version of the implementation for it that I could compile: vladbat00@ed25a8c
examples/ecs/query_views.rs
example is working, but if you add another call ofq.iter_mut()
insideservice
function, the compilation will fail. And it's pretty much obvious to me why:iter_mut
signature makes it so thatself
is borrowed for'q
lifetime, which is practically the lifetime of the query itself.Unfortunately, I can't come up with anything else that would compile. If anyone could help me to figure out how to get rid of
'q
lifetime forfn iter_mut(&'q mut self)
, I'd be very grateful.Beta Was this translation helpful? Give feedback.
All reactions