Skip to content

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