-
-
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
Round out Mut<T> api using lenses + auto-unwrapping #4413
Conversation
@@ -124,7 +124,7 @@ pub fn calculate_bounds( | |||
} | |||
|
|||
pub fn update_frusta<T: Component + CameraProjection + Send + Sync + 'static>( | |||
mut views: Query<(&GlobalTransform, &T, &mut Frustum)>, | |||
mut views: Query<(&GlobalTransform, Raw<T>, &mut Frustum)>, |
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.
The need for this sort of change makes me worried: I don't love that users will have to reason about this when trying to write generic systems.
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.
Maybe, but it's a fairly mindless fix - just use the Raw and RawMut wrappers for directly generic components. I think ergonomic wins for the more common cases outweigh this slight loss here.
Interesting. My first impressions are:
|
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This only holds until we have |
Closed in favor of #6199. |
Objective
Mut<LargeStruct>
toMut<Field>
Solution
Add lenses, which allow for getting a
Mut<U>
from aMut<T>
whereT
contains aU
, and add a "default lens" option to theComponent
trait, allowing for automatic unwrapping of newtypesChangelog
Lens
traitDefaultLens
associated type toComponent
for automatic lensingRaw
andRawMut
query params which bypass automatic lensing