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

Or<T> should be a new type of PhantomData<T> #8212

Merged
merged 1 commit into from
Mar 26, 2023

Conversation

orzogc
Copy link
Contributor

@orzogc orzogc commented Mar 25, 2023

Objective

Or<T> should be a new type of PhantomData<T> instead of T.

Solution

Make Or<T> a new type of PhantomData<T>.

Migration Guide

Or<T> is just used as a type annotation and shouldn't be constructed.

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR labels Mar 25, 2023
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@alice-i-cecile alice-i-cecile removed the X-Controversial There is active debate or serious implications around merging this PR label Mar 25, 2023
@alice-i-cecile
Copy link
Member

Tricky. I thought this could be used to fetch data as well, much like AnyOf.

In that case, I would expect the stored type to be a collection of Option<T::Item>, not PhantomData<T>. But that's incorrect: the following code compiles.

use bevy::prelude::*;

fn my_system(query: Query<Or<(&Transform, &BackgroundColor)>>) {
    let query_item: bool = query.single();
}

TL;DR: this is the right fix. #7680 strikes again.

@alice-i-cecile
Copy link
Member

(I have no idea what to put in the migration guide, but this is technically a breaking change)

@james7132 james7132 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 26, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 26, 2023
Merged via the queue into bevyengine:main with commit e71078a Mar 26, 2023
@orzogc orzogc deleted the fix-or branch March 26, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants