Skip to content

Clone and IntoIter support for queries #1631

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

Itertools has a great number of fantastic, ergonomic ways to work with iterators, like cartesian product, combinations etc that would be regularly used in games. I would love to be able to use this with my queries, but I can't due to lacking trait impls.

What solution would you like?

impl Clone, IntoIter and any other necessary traits on both Query and QueryIter.

What alternative(s) have you considered?

Write replacements for these methods by hand, either in the engine itself or in each game's code.

Additional context

One of the features of itertools (exactly_one) was reinvented in #1263 already.

Here's a nice code snippet that I would like to be able to compile showing the building block methods:

   use bevy::prelude::*;
   
    struct Foo;
    fn my_system(query: Query<&Foo>) {
        query.clone();
        query.into_iter();
        query.iter();
        query.iter().clone();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions