Skip to content

Commit 7f9aa2b

Browse files
committed
rand_distr: fix no_std build
1 parent 19404d6 commit 7f9aa2b

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

rand_distr/src/binomial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use crate::{Distribution, Uniform};
1313
use rand::Rng;
1414
use core::fmt;
1515
use core::cmp::Ordering;
16+
#[allow(unused_imports)]
17+
use num_traits::Float;
1618

1719
/// The binomial distribution `Binomial(n, p)`.
1820
///

rand_distr/src/geometric.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use crate::Distribution;
44
use rand::Rng;
55
use core::fmt;
6+
#[allow(unused_imports)]
7+
use num_traits::Float;
68

79
/// The geometric distribution `Geometric(p)` bounded to `[0, u64::MAX]`.
810
///

rand_distr/src/hypergeometric.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use crate::Distribution;
44
use rand::Rng;
55
use rand::distributions::uniform::Uniform;
66
use core::fmt;
7+
#[allow(unused_imports)]
8+
use num_traits::Float;
79

810
#[derive(Clone, Copy, Debug)]
911
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]

rand_distr/src/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use crate::ziggurat_tables;
1212
use rand::distributions::hidden_export::IntoFloat;
1313
use rand::Rng;
14+
use num_traits::Float;
1415

1516
/// Calculates ln(gamma(x)) (natural logarithm of the gamma
1617
/// function) using the Lanczos approximation.
@@ -25,7 +26,7 @@ use rand::Rng;
2526
/// `Ag(z)` is an infinite series with coefficients that can be calculated
2627
/// ahead of time - we use just the first 6 terms, which is good enough
2728
/// for most purposes.
28-
pub(crate) fn log_gamma<F: num_traits::Float>(x: F) -> F {
29+
pub(crate) fn log_gamma<F: Float>(x: F) -> F {
2930
// precalculated 6 coefficients for the first 6 terms of the series
3031
let coefficients: [F; 6] = [
3132
F::from(76.18009172947146).unwrap(),

0 commit comments

Comments
 (0)