summaryrefslogtreecommitdiff
path: root/rand/src/distributions/utils.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2020-01-02 08:32:06 -0800
committerDaniel Mueller <deso@posteo.net>2020-01-02 08:32:06 -0800
commitfd091b04316db9dc5fafadbd6bdbe60b127408a9 (patch)
treef202270f7ae5cedc513be03833a26148d9b5e219 /rand/src/distributions/utils.rs
parent8161cdb26f98e65b39c603ddf7a614cc87c77a1c (diff)
downloadnitrocli-fd091b04316db9dc5fafadbd6bdbe60b127408a9.tar.gz
nitrocli-fd091b04316db9dc5fafadbd6bdbe60b127408a9.tar.bz2
Update nitrokey crate to 0.4.0
This change finally updates the version of the nitrokey crate that we consume to 0.4.0. Along with that we update rand_core, one of its dependencies, to 0.5.1. Further more we add cfg-if in version 0.1.10 and getrandom in version 0.1.13, both of which are now new (non-development) dependencies. Import subrepo nitrokey/:nitrokey at e81057037e9b4f370b64c0a030a725bc6bdfb870 Import subrepo cfg-if/:cfg-if at 4484a6faf816ff8058088ad857b0c6bb2f4b02b2 Import subrepo getrandom/:getrandom at d661aa7e1b8cc80b47dabe3d2135b3b47d2858af Import subrepo rand/:rand at d877ed528248b52d947e0484364a4e1ae59ca502
Diffstat (limited to 'rand/src/distributions/utils.rs')
-rw-r--r--rand/src/distributions/utils.rs30
1 files changed, 7 insertions, 23 deletions
diff --git a/rand/src/distributions/utils.rs b/rand/src/distributions/utils.rs
index d4d3642..3af4e86 100644
--- a/rand/src/distributions/utils.rs
+++ b/rand/src/distributions/utils.rs
@@ -11,9 +11,9 @@
#[cfg(feature="simd_support")]
use packed_simd::*;
#[cfg(feature="std")]
-use distributions::ziggurat_tables;
+use crate::distributions::ziggurat_tables;
#[cfg(feature="std")]
-use Rng;
+use crate::Rng;
pub trait WideningMultiply<RHS = Self> {
@@ -61,7 +61,7 @@ macro_rules! wmul_impl {
wmul_impl! { u8, u16, 8 }
wmul_impl! { u16, u32, 16 }
wmul_impl! { u32, u64, 32 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
+#[cfg(not(target_os = "emscripten"))]
wmul_impl! { u64, u128, 64 }
// This code is a translation of the __mulddi3 function in LLVM's
@@ -125,9 +125,9 @@ macro_rules! wmul_impl_large {
)+
};
}
-#[cfg(not(all(rustc_1_26, not(target_os = "emscripten"))))]
+#[cfg(target_os = "emscripten")]
wmul_impl_large! { u64, 32 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
+#[cfg(not(target_os = "emscripten"))]
wmul_impl_large! { u128, 64 }
macro_rules! wmul_impl_usize {
@@ -249,13 +249,9 @@ pub(crate) trait FloatSIMDUtils {
/// Implement functions available in std builds but missing from core primitives
#[cfg(not(std))]
pub(crate) trait Float : Sized {
- type Bits;
-
fn is_nan(self) -> bool;
fn is_infinite(self) -> bool;
fn is_finite(self) -> bool;
- fn to_bits(self) -> Self::Bits;
- fn from_bits(v: Self::Bits) -> Self;
}
/// Implement functions on f32/f64 to give them APIs similar to SIMD types
@@ -289,8 +285,6 @@ macro_rules! scalar_float_impl {
($ty:ident, $uty:ident) => {
#[cfg(not(std))]
impl Float for $ty {
- type Bits = $uty;
-
#[inline]
fn is_nan(self) -> bool {
self != self
@@ -305,17 +299,6 @@ macro_rules! scalar_float_impl {
fn is_finite(self) -> bool {
!(self.is_nan() || self.is_infinite())
}
-
- #[inline]
- fn to_bits(self) -> Self::Bits {
- unsafe { ::core::mem::transmute(self) }
- }
-
- #[inline]
- fn from_bits(v: Self::Bits) -> Self {
- // It turns out the safety issues with sNaN were overblown! Hooray!
- unsafe { ::core::mem::transmute(v) }
- }
}
impl FloatSIMDUtils for $ty {
@@ -383,6 +366,7 @@ macro_rules! simd_impl {
<$ty>::from_bits(<$uty>::from_bits(self) + <$uty>::from_bits(mask))
}
type UInt = $uty;
+ #[inline]
fn cast_from_int(i: Self::UInt) -> Self { i.cast() }
}
}
@@ -464,7 +448,7 @@ pub fn ziggurat<R: Rng + ?Sized, P, Z>(
mut pdf: P,
mut zero_case: Z)
-> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
- use distributions::float::IntoFloat;
+ use crate::distributions::float::IntoFloat;
loop {
// As an optimisation we re-implement the conversion to a f64.
// From the remaining 12 most significant bits we use 8 to construct `i`.