Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hecs::Query should handle type parameters #359

Open
sanbox-irl opened this issue Dec 18, 2023 · 2 comments
Open

hecs::Query should handle type parameters #359

sanbox-irl opened this issue Dec 18, 2023 · 2 comments

Comments

@sanbox-irl
Copy link
Contributor

Basically I'd love this to work:

#[derive(hecs::Query)]
pub struct DrawSpriteQuery<'a, SpriteLike = Sprite> {
    pub transform: &'a Transform,
    pub sprite: &'a SpriteLike,
    pub shader_routine: &'a crate::gfx::ShaderRoutine,
    pub size: Option<&'a Size>,
}

I'll take a look in the macro to see how tough it would be, but I suspect not terribly difficult, but not sure!

@Ralith
Copy link
Owner

Ralith commented Dec 18, 2023

The easy and composable thing would be to assume all type parameters are Querys and do <'a, SpriteLike = &'a Sprite> and pub sprite: SpriteLike. The general case, including your example as written, probably requires allowing the user to specify custom bounds.

@Ralith
Copy link
Owner

Ralith commented Dec 18, 2023

On second thought, if we just pass through the bounds specified on the type, we can probably handle all cases gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants