Repository navigation
The iter_many_mut documentation is confused #5506
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-DocsAn addition or correction to our documentationAn addition or correction to our documentation
Description
Activity
- addedC-DocsAn addition or correction to our documentationAn addition or correction to our documentationA-ECSEntities, components, systems, and eventsEntities, components, systems, and events
on Jul 31, 2022 I'll rebase #4989 to
mainand add more appropriate doc comments.To add to this, it would be helpful to add a mention that the returned value is not actually an
Iterator. I was confused by the errors when I triedfor foo in q.iter_many_mut(&entities) {}
The comment on the
Iteratorimpl forQueryManyIterexplains this a bit:/// Iterator type is intentionally implemented only for read-only access. /// Doing so for mutable references would be unsound, /// because calling `next` multiple times would allow multiple owned references to the same data to exist.
but it might be good to mention as well on
iter_many_mutas well, to explain the need for this usage (which can easily be misread as the more commonwhile let Some(_) = it.next():let mut it = q.iter_many_mut(&entities) while let Some(foo) = it.fetch_next() {}
Reacted by Felix Rath- added 2 commits that reference this issue
on Sep 2, 2022 - added a commit that references this issue
on Oct 28, 2022 - added a commit that references this issue
on Feb 1, 2023
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-DocsAn addition or correction to our documentationAn addition or correction to our documentation
The documentation talks about calling a "closure", but
iter_many_mutdoesn't have a closure argument, as the example shows. https://docs.rs/bevy/latest/bevy/ecs/system/struct.Query.html#method.iter_many_mut