Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Standard should be implemented for NonZero types #727

Closed
joshlf opened this issue Feb 12, 2019 · 2 comments
Closed

Standard should be implemented for NonZero types #727

joshlf opened this issue Feb 12, 2019 · 2 comments

Comments

@joshlf
Copy link
Contributor

joshlf commented Feb 12, 2019

Now that the standard library NonZeroXXX types have been stabilized, Standard should support them.

@TheIronBorn
Copy link
Contributor

TheIronBorn commented Feb 12, 2019

In the meantime, this should work:

let distr = Uniform::new_inclusive(1, u32::max_value()); 
let sample = rng.sample(distr); 
NonZeroU32::new(sample)
// or
NonZeroI32::new(sample as i32)

@joshlf
Copy link
Contributor Author

joshlf commented Feb 12, 2019

@TheIronBorn Cool, thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants