Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.65k stars 465 forks source link

`unsafe_textures` feature flag is not additive #1410

Open antonilol opened 2 weeks ago

antonilol commented 2 weeks ago

Reference on feature flags: https://doc.rust-lang.org/cargo/reference/features.html#feature-unification

If I, in a library, use Texture<'a> and a user of my library enables the unsafe_textures feature flag on sdl2, then the code in the library no longer compiles, because the changes (the difference between having unsafe_textures enabled or disabled) are not SemVer compatible.

I suggest making a new struct, that wraps Texture<'static> (or the contents of it) and provides unsafe methods to use it (unsafe because it is not known if the pointer is still valid), could even be without feature flag to allow using both, where needed. (I did not test this, so this idea to fix this might not be entirely accurate)

antonilol commented 2 weeks ago

looks to be the case for hidapi as well, adding and removing an enum member is a breaking change.

event.rs:301, enum member is cfg'ed out:

    #[cfg(feature = "hidapi")]
    ControllerSensorUpdated = SDL_EventType::SDL_CONTROLLERSENSORUPDATE as u32,
Cobrand commented 1 week ago

Impossible without features for the first one unfortunately.

For Hidapi I think the feature can be removed as it used to be experimental in SDL2 but now is quite stable, but I'm not 100% sure.