-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
There was a problem hiding this 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()
.
There was a problem hiding this 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
crates/bevy_reflect/src/map.rs
Outdated
@@ -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. |
There was a problem hiding this comment.
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)
/// 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. |
crates/bevy_reflect/src/map.rs
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Possible re-phrasing:
/// 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Objective
Fixes #8596
Solution
Change interface of the trait Map. Adjust implementations of this trait
Changelog
Changed
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.