Hello. I have a function called in a system, with a query parameter defined like so:
pheromone_query: &mut Query<&mut Pheromone>
I'm using both get and get_mut for some operations, and obviously Rust started screaming at me. The error's the following:
| 214 | let mut local_pheromone = pheromone_query.get_mut(*local_pheromone).unwrap(); | ----------------------------------------- mutable borrow occurs here ... 244 | let adjacent_pheromone = pheromone_query.get(*adjacent_pheromone).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ immutable borrow occurs here ... 260 | local_pheromone.intensity = max_pheromone_intensity; | --------------- mutable borrow later used here
Now, what I'm doing is getting a specific pheromone, analyzing the pheromones around it and updating the initial pheromone intensity. Since this isn't being done in parallel or anything, I don't understand why it's claiming the mutable borrow (for the query?) is being used at line 260, since i'm simply updating a field of the pheromone i already fetched mutably. Can anyone help me understand what's going on? I saw in the cheat book the chapter about ParamSets but I don't think my case requires it, i'm confused. Thanks in advance! (The unwrap is temporary, I swear :^) )