Skip to content
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

[WIP] Conversion fn prefixes: change to fit Rust's convention #1037

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

danielrempel
Copy link

Fix #1036

Please review the changes.

I tried to strive to these rules, but I'm not sure about some of the changes I made. Most important to me was to change Surface::as_texture() to Surface::to_texture()

I'm not sure about src/sdl2/joystick.rs-s HatState::as_raw(), because it's owned and I believe it's Copy, too, so according to the table it should be to_raw()?

Prefix Cost Ownership
as_ Free borrowed -> borrowed
to_ Expensive borrowed -> borrowed
to_ Expensive borrowed -> owned (non-Copy types)
to_ Expensive owned -> owned (Copy types)
into_ Variable owned -> owned (non-Copy types)

@Cobrand
Copy link
Member

Cobrand commented Oct 23, 2020

I agree with everything expect window and surface which IMO shouldn't be changed. The idea in those cases is that they are accessors, and you can do stuff like

canvas.window_mut().set_title("Some title"). Aside from that you can't really "use" SurfaceRef and WindowRef.

This is exactly like io::Error's kind method, and many others taht exist in the std : io::error kind. Notice that the method is called kind() and not as_kind()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Change conversion functions to conform to Rust's convention
2 participants