-
Notifications
You must be signed in to change notification settings - Fork 424
Improve sub-context passing ergonomics #1037
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
Conversation
Interesting idea! It certainly improves ergonomics.
It certainly is a bit ugly, but for a library of our size and ambition (i.e. making life as easy as possible) it makes sense to me. |
fair, or
sure, I'll write some documentation tomorrow |
changed the last two public functions taking references to GraphicsContext towards using Has and HasMut; fixed clippy lints; resolved failing tests (except skeptic for some reason);
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.
Almost finished. I found some final places where the Has
-pattern hadn't yet been adopted and also changed some tiny other things, see the PR.
small patch
this allows passing just
ctx
to functions that take sub-contexts.You can still split borrow with a slightly uglier construction:
&(&ctx.fs, &ctx.gfx)
.I think something like 99.9% of users won't ever have to split borrow so in my opinion, this is a good trade-off.