diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-16 17:26:30 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-16 17:26:30 -0800 |
commit | 8350ac6afb2d678b74581000a6aafe1994b72231 (patch) | |
tree | 2330da01a806921b3849c9e64d2b9f506495e2c0 /rand/src/distributions/unit_circle.rs | |
parent | d6652b913b33e432a748187f9f5623cec1e9926e (diff) | |
download | nitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.gz nitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.bz2 |
Update nitrokey crate to 0.3.3
This change updates the nitrokey crate to version 0.3.3. Along with that
change we update rand to 0.6.4 because rand 0.6.1 does not yet contain a
publicly accessible rand_os. Note that we no longer require all
crates in rand's workspace, but only rand_os and rand_core, which is a
significant reduction in the number of lines of code compiled.
Import subrepo nitrokey/:nitrokey at 7cf747d56ddc0b7eeedc3caf36dcc909907a171c
Import subrepo rand/:rand at 4336232dda03323634b10ec72ddf27914aebc3a2
Diffstat (limited to 'rand/src/distributions/unit_circle.rs')
-rw-r--r-- | rand/src/distributions/unit_circle.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/rand/src/distributions/unit_circle.rs b/rand/src/distributions/unit_circle.rs index abb36dc..01ab76a 100644 --- a/rand/src/distributions/unit_circle.rs +++ b/rand/src/distributions/unit_circle.rs @@ -29,27 +29,26 @@ use distributions::{Distribution, Uniform}; /// NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing /// Office, pp. 36-38. #[derive(Clone, Copy, Debug)] -pub struct UnitCircle { - uniform: Uniform<f64>, -} +pub struct UnitCircle; impl UnitCircle { /// Construct a new `UnitCircle` distribution. #[inline] pub fn new() -> UnitCircle { - UnitCircle { uniform: Uniform::new(-1., 1.) } + UnitCircle } } impl Distribution<[f64; 2]> for UnitCircle { #[inline] fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 2] { + let uniform = Uniform::new(-1., 1.); let mut x1; let mut x2; let mut sum; loop { - x1 = self.uniform.sample(rng); - x2 = self.uniform.sample(rng); + x1 = uniform.sample(rng); + x2 = uniform.sample(rng); sum = x1*x1 + x2*x2; if sum < 1. { break; |