Newbie question about mutable queries and lifetimes #3799
-
Hello! Let me start by saying that I really think that bevy is a great game engine in the making. I'm not new to programming, but new to rust and was searching for a project to develop my rust skills. Trying to write a small game with bevy is exactly what I needed to keep me motivated. That said, I'm still struggling with some of the ways Rust forces one write the code. One such thing is the borrow checker, lifetimes and mutability. With some patience and effort I was able to decipher and solve most of my problems, but now I'm stuck. I have a system, that gets a mutable query to lookup the visibility of some entities and modify it. The following code is a simplification of the actual code.
As you may notice, the code doesn't compile because of missing lifetime specifiers. But even when I was able to somehow get rid of the lifetime specifier errors, it would not let me call the I tried to use So I came to the conclusion, that I need help on how to fix the code snipped above. Maybe this is the wrong forum to ask this question. In this case I would humbly ask for directions to the correct forum and offer my apologies. Nevertheless, I would like to thank you for your great work and help in advance.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Fortunately this has an easy solution! Instead of searching using |
Beta Was this translation helpful? Give feedback.
Fortunately this has an easy solution! Instead of searching using
.iter().find()
you should usequery.get(entity)
. Let me know if this solves tour problem! :)