-
Notifications
You must be signed in to change notification settings - Fork 432
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
Make NewRng::new() return Self without Result wrapper #302
Conversation
Advantage: more convenient way to call an fn which almost never fails.
There was a problem hiding this 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!
As you argued, new()
is extremely unlikely to fail, a convenience function, and an alternative that does return errors is easily available.
the comment that directs users to use RNG::from_rng should instead say
SeedableRng::from_rng instead.
…On Mar 15, 2018 10:41 AM, "Diggory Hardy" ***@***.***> wrote:
Merged #302 <#302>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#302 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0jI70lJQLasyAjEwzIgsQ_6k4GRNks5teikngaJpZM4Sq8Lz>
.
|
Do we need to use UFCS here? |
It wasn’t obvious to me (although I haven’t taken time to familiarise myself fully with new trait hierarchy yet), and first look at the recommendation seemed to imply that It seems to me that users who will be reading this comment will be operating in the generic context anyway, so their code will be something like this:
Then recommending to use
|
Ah, sorry, I should have left this open for comment longer. We have quite a lot of PRs at the moment. I'm assuming actually that many people will not be using generic types, though sure, sometimes they will, so for example: use rand::{Rng, NewRng, SmallRng};
// This will only fail if something is quite wrong with the platform;
// in this case better just to die anyway:
let mut rng = SmallRng::new(); But sure, your generic version works too. |
Make NewRng::new() return Self without Result wrapper
Advantage: more convenient way to call an fn which almost never fails.