-
Notifications
You must be signed in to change notification settings - Fork 473
Upgrade rand crate or make it optional #938
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
Comments
I'm all for changing rand as an optional dependency (and upgrade it). Very few users will be using rand with Sdl2, most of them who need it will use a wrapper around SdlColor and implement Rand for that. We could even argue it's not used at all and remove it entirely, I'm sure no one will say anything (you can replicate this code with a few lines regardless). |
@Cobrand I can open a PR if you wish, however, what should I do for now? Just upgrade Also, how often a new version of |
I think remove it altogether is the better choice. There is no fixed schedule for crates.io updates, I usually do it when I have time to clean the changelog and make sure everything works alright with the past few PRs. The master branch is pretty unstable, you can make breaking changes, people are expected to use the versions from crates.io. |
Problem
The
rand
crate is one of the dependencies of this crate. However, it is used in literally only one place:rust-sdl2/src/sdl2/pixels.rs
Lines 174 to 182 in 0be6aaf
First of all, while random number generation is a common requirement in graphical applications (e.g. games) it is not always. Although this is not my main concern. The
sdl2
crate depends on an outdated version ofrand
,^0.6
. This results in the following dependency graph insidesdl2
:See? This pulls in two different versions of
rand_core
-0.3.1
and0.4.2
. Obvious code duplication. The total number of dependencies ofsdl2
is 41.Solution
This simple patch reduces dependency count to 33 and removes duplication of the mentioned crate
rand_core
:However, we can go even further and make
rand
an optional dependency with this patch:Summary
Right now I propose to only update the version of
rand
dependency because this is a trivial change. Although I also would like the developers ofrust-sdl2
to consider makingrand
an optional dependency (but only if the implications of such change won't be too significant).The text was updated successfully, but these errors were encountered: