Skip to content
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

Remove RNG traits in favor of rand_core. #270

Closed
wants to merge 3 commits into from

Conversation

jounathaen
Copy link

@jounathaen jounathaen commented Apr 27, 2021

As proposed in #128 here is a PR that completely removes the RNG traits from the embedded-hal.
This closes #128.

Reasoning:

The rand_core crate already implements relevant traits for random number generation. A HAL which provides access to an RNG peripheral should implement these traits instead (Example: stm32f4xx-hal) and a driver should rely on these.

Impact:

This is a breaking change. Should be done before a 1.0.0 release.

Alternatives

The [rand_core](https://crates.io/crates/rand_core) crate already
implements relevant traits for random number generation. A HAL which
provides access to a RNG peripheral should implement these traits
instead and a driver should rely on these.
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@jounathaen
Copy link
Author

In the discussion, it was mentioned that some pointers and documentation on this change are required. I'm not sure on where to do this. The release notes seem to be the best place as it is hard to document stuff that is not existing anymore.

@jounathaen
Copy link
Author

It's probably wiser to first mark the traits as deprecated as in #271 before removing them.

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks! I would go ahead with the removal without deprecation step.
Any objections @rust-embedded/hal?

CHANGELOG.md Outdated Show resolved Hide resolved
@eldruin eldruin added this to the v1.0.0 milestone Apr 27, 2021
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
@ryankurte
Copy link
Contributor

i'm okay with it, maybe it'd be nice to have a note in the docs somewhere to go looking at rand_core?

@jounathaen
Copy link
Author

Regarding the documentation: One could re-add the modules but without the traits and only with a note to rand_core.
I've already prepared the commit (but I've not added it to this PR yet to avoid commit spam).

@eldruin
Copy link
Member

eldruin commented Apr 28, 2021

I would add the documentation note but not the rng module, since removing it would technically be a breaking change.

@jounathaen
Copy link
Author

I would add the documentation note but not the rng module, since removing it would technically be a breaking change.

Sorry, but I didn't fully understand where you think the note should go.

@eldruin
Copy link
Member

eldruin commented Apr 28, 2021

I think I would put it somewhere in lib.rs.

@eldruin eldruin mentioned this pull request Jun 30, 2021
@bors bors bot closed this in 113cb81 Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Review is incomplete T-hal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discussion] rand::RngCore for blocking RNG trait
5 participants