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

Add get_at_mut to bevy_reflect::Map trait #8691

Merged
merged 3 commits into from
Jun 2, 2023

Conversation

TheBlek
Copy link
Contributor

@TheBlek TheBlek commented May 27, 2023

Objective

Fixes #8596

Solution

Change interface of the trait Map. Adjust implementations of this trait


Changelog

Changed

  • Interface of Map trait

Added

  • Map::get_at_mut

Migration Guide

Every implementor of Map trait would need to implement get_at_mut. Which, judging by changes in this PR, should be fairly trivial.

@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 ✨

@MrGVSV MrGVSV self-requested a review May 27, 2023 05:34
@djeedai djeedai added C-Feature A new feature, making something new possible A-Reflection Runtime information about types labels May 27, 2023
Copy link
Contributor

@djeedai djeedai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks fine based on similitude with get_at().

Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just a couple comments

@@ -49,9 +49,12 @@ pub trait Map: Reflect {
/// If no value is associated with `key`, returns `None`.
fn get_mut(&mut self, key: &dyn Reflect) -> Option<&mut dyn Reflect>;

/// Returns the key-value pair at `index` by reference, or `None` if out of bounds.
/// Returns the key-value pair at `index` by references, or `None` if out of bounds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think the original was actually correct (could be wrong)

Suggested change
/// Returns the key-value pair at `index` by references, or `None` if out of bounds.
/// Returns the key-value pair at `index` by reference, or `None` if out of bounds.

fn get_at(&self, index: usize) -> Option<(&dyn Reflect, &dyn Reflect)>;

/// Returns the key-value pair at `index` by references where value reference is mutable, or `None` if out of bounds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Possible re-phrasing:

Suggested change
/// Returns the key-value pair at `index` by references where value reference is mutable, or `None` if out of bounds.
/// Returns the key-value pair at `index` by reference where the value is a mutable reference, or `None` if out of bounds.

Copy link
Member

@MrGVSV MrGVSV May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add a test that ensures get_at_mut is working as intended?

Edit: I guess we don't actually have one for get_at 😅. Would you be able to add one for that as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I tried to write tests as helpful as possible, but still not sure whether they are. Looking forward to your feedback on that

@TheBlek TheBlek requested a review from MrGVSV May 28, 2023 00:55
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution!

@MrGVSV MrGVSV 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 May 29, 2023
@alice-i-cecile alice-i-cecile changed the title Add get_at_mut to Map trait Add get_at_mut to bevy_reflect::Map trait May 29, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 2, 2023
Merged via the queue into bevyengine:main with commit 6b4c7d5 Jun 2, 2023
@Selene-Amanita Selene-Amanita added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Feature A new feature, making something new possible 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
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Add get_at_mut to Map trait
5 participants