From 8350ac6afb2d678b74581000a6aafe1994b72231 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Wed, 16 Jan 2019 17:26:30 -0800 Subject: 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 --- rand/src/distributions/unit_sphere.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'rand/src/distributions/unit_sphere.rs') diff --git a/rand/src/distributions/unit_sphere.rs b/rand/src/distributions/unit_sphere.rs index 61cbda5..37de88b 100644 --- a/rand/src/distributions/unit_sphere.rs +++ b/rand/src/distributions/unit_sphere.rs @@ -28,23 +28,22 @@ use distributions::{Distribution, Uniform}; /// Sphere.*](https://doi.org/10.1214/aoms/1177692644) /// Ann. Math. Statist. 43, no. 2, 645--646. #[derive(Clone, Copy, Debug)] -pub struct UnitSphereSurface { - uniform: Uniform, -} +pub struct UnitSphereSurface; impl UnitSphereSurface { /// Construct a new `UnitSphereSurface` distribution. #[inline] pub fn new() -> UnitSphereSurface { - UnitSphereSurface { uniform: Uniform::new(-1., 1.) } + UnitSphereSurface } } impl Distribution<[f64; 3]> for UnitSphereSurface { #[inline] fn sample(&self, rng: &mut R) -> [f64; 3] { + let uniform = Uniform::new(-1., 1.); loop { - let (x1, x2) = (self.uniform.sample(rng), self.uniform.sample(rng)); + let (x1, x2) = (uniform.sample(rng), uniform.sample(rng)); let sum = x1*x1 + x2*x2; if sum >= 1. { continue; -- cgit v1.2.1