You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got used to Rust's naming conventions and among them there's a less official one that recommends to name 'free' type casting functions as 'as_something()' and expensive ones as 'to_something()'
Surface::as_texture() actually creates a new texture and copies surface data into it, so I believe it should be named to_texture()
Grep'ed the code and found several more cases like:
./src/sdl2/video.rs:98: fn to_gl_value(self) -> i32 { self as i32 }
It is problematic to change the APIs as there must be a lot of projects building on top of rust-sdl2, but maybe as_texture() and others could be declared obsolete and removed when version bump allows that?
You could rename the old to the new functions, but still keep the old ones as an alias to the new ones, and mark them as deprecated. After a few versions, we could remove them entirely and get rid of the deprecation markers.
Well the important reason why as_foo is cheap is because it's supposed to be reference to reference, and then to_foo is potentially expensive because it's owned to owned.
So Surface -> Texture should be to_texture but GL data type casting should also be to_gl_value
Got used to Rust's naming conventions and among them there's a less official one that recommends to name 'free' type casting functions as 'as_something()' and expensive ones as 'to_something()'
Surface::as_texture()
actually creates a new texture and copies surface data into it, so I believe it should be namedto_texture()
Grep'ed the code and found several more cases like:
It is problematic to change the APIs as there must be a lot of projects building on top of rust-sdl2, but maybe
as_texture()
and others could be declared obsolete and removed when version bump allows that?Rust supports deprecation marks
Semver 2.0 requires a minor version bump to deprecate and then a major bump to remove deprecated methods
I could do the changes myself if you agree that they are reasonable / worthy :)
The text was updated successfully, but these errors were encountered: