-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 MutUntyped::map_unchanged
#9194
Conversation
Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com>
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.
Thank you for adopting this!
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.
I agree with the doc suggestions but won't block on them.
Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com>
Uh huh... For some reason CI is failing now, but I don't really understand why, I only committed the doc suggestions |
One of my suggestions must have had an extra space or something -- you should be able to just run |
Miri failure is due to a but in rust nightly, it should be fixed tomorrow |
Adopted #6430
Objective
MutUntyped
is the untyped variant ofMut<T>
that stores aPtrMut
instead of a&mut T
. Working with aMutUntyped
is a bit annoying, because as soon you want to use the ptr e.g. as a&mut dyn Reflect
you cannot use a type likeMut<dyn Reflect>
but instead need to carry around a&mut dyn Reflect
and 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
Mut
that will dereference to that value and mark the original value as changed. The lifetimes here prevent anything bad from happening.Alternatives
Ticks
public and provide a method to get construct aMut
fromTicks
and&mut T
. More powerful and more easy to misuse.&mut dyn Reflect, impl FnMut() + '_)
around instead ofMut<dyn Reflect>
Changelog
MutUntyped::map_unchanged
to turn aMutUntyped
into its typed counterpart