Skip to content

[Proposal] Change conversion functions to conform to Rust's convention #1036

Open
@danielrempel

Description

@danielrempel

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?

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions