bevy/crates/bevy_ecs/src
Zachary Harrold 5cc3f4727e
Implement Clone for QueryIter over read-only data (#17391)
# Objective

- Fix issue identified on the [Discord
server](https://discord.com/channels/691052431525675048/691052431974465548/1328922812530036839)

## Solution

- Implement `Clone` for `QueryIter` using the existing
`QueryIter::remaining` method

## Testing

- CI

---

## Showcase

Users can now explicitly clone a read-only `QueryIter`:

```rust
fn combinations(query: Query<&ComponentA>) {
    let mut iter = query.iter();
    while let Some(a) = iter.next() {
        // Can now clone rather than use remaining
        for b in iter.clone() {
            // Check every combination (a, b)
        }
    }
}
```


## Notes

This doesn't add any new functionality outside the context of generic
code (e.g., `T: Iterator<...> + Clone`), it's mostly for
discoverability. Users are more likely to be familiar with
`Clone::clone` than they are with the methods on `QueryIter`.
2025-01-15 21:56:11 +00:00
..
entity bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
event Remove Event: Component trait bound using a wrapper type which impls Component (#17380) 2025-01-15 18:42:47 +00:00
identifier bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
observer Remove Event: Component trait bound using a wrapper type which impls Component (#17380) 2025-01-15 18:42:47 +00:00
query Implement Clone for QueryIter over read-only data (#17391) 2025-01-15 21:56:11 +00:00
reflect Fix entity does not exist message on index reuse (#17264) 2025-01-12 05:39:54 +00:00
schedule added any_match_filter common condition (#17327) 2025-01-14 21:53:35 +00:00
storage Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
system fix typo query.rs (#17366) 2025-01-14 21:53:19 +00:00
world Remove Event: Component trait bound using a wrapper type which impls Component (#17380) 2025-01-15 18:42:47 +00:00
archetype.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
batching.rs Fix *most* clippy lints (#15906) 2024-10-14 20:52:35 +00:00
bundle.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
change_detection.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
component.rs Rename track_change_detection flag to track_location (#17075) 2025-01-01 18:43:47 +00:00
intern.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
label.rs Add compile-time dyn compatible checks for DynEq, DynHash (#17254) 2025-01-09 07:30:54 +00:00
lib.rs Move #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] to the workspace Cargo.toml (#17374) 2025-01-15 01:14:58 +00:00
name.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
removal_detection.rs Replace map + unwrap_or(true) with is_none_or (#17070) 2024-12-31 20:17:03 +00:00
result.rs Add no_std support to bevy_ecs (#16758) 2024-12-17 21:40:36 +00:00
traversal.rs Window picking (#16103) 2024-12-05 21:14:39 +00:00