add MutUntyped::map_unchanged#9194
Merged
mockersf merged 13 commits intobevyengine:mainfrom Jul 23, 2023
Serverator:mutuntyped-to-typed
Merged
add MutUntyped::map_unchanged#9194mockersf merged 13 commits intobevyengine:mainfrom Serverator:mutuntyped-to-typed
MutUntyped::map_unchanged#9194mockersf merged 13 commits intobevyengine:mainfrom
Serverator:mutuntyped-to-typed
Conversation
Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com>
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
joseph-gio
approved these changes
Jul 21, 2023
Member
joseph-gio
left a comment
There was a problem hiding this comment.
Thank you for adopting this!
alice-i-cecile
approved these changes
Jul 21, 2023
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
I agree with the doc suggestions but won't block on them.
Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com>
Contributor
Author
|
Uh huh... For some reason CI is failing now, but I don't really understand why, I only committed the doc suggestions |
Member
|
One of my suggestions must have had an extra space or something -- you should be able to just run |
joseph-gio
reviewed
Jul 22, 2023
Member
|
Miri failure is due to a but in rust nightly, it should be fixed tomorrow |
mockersf
approved these changes
Jul 23, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopted #6430
Objective
MutUntypedis the untyped variant ofMut<T>that stores aPtrMutinstead of a&mut T. Working with aMutUntypedis a bit annoying, because as soon you want to use the ptr e.g. as a&mut dyn Reflectyou cannot use a type likeMut<dyn Reflect>but instead need to carry around a&mut dyn Reflectand aimpl FnMut()to mark the value as changed.Solution
Note that nothing prevents you from doing
or using any other mutable reference you can get, but IMO that is fine since that will only result in a
Mutthat will dereference to that value and mark the original value as changed. The lifetimes here prevent anything bad from happening.Alternatives
Tickspublic and provide a method to get construct aMutfromTicksand&mut T. More powerful and more easy to misuse.&mut dyn Reflect, impl FnMut() + '_)around instead ofMut<dyn Reflect>Changelog
MutUntyped::map_unchangedto turn aMutUntypedinto its typed counterpart