Bump to 0.3.7 for Copy/Clone changes
diff --git a/Cargo.toml b/Cargo.toml
index 8defe31..79ae8c7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "rand"
-version = "0.3.6"
+version = "0.3.7"
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
diff --git a/src/distributions/exponential.rs b/src/distributions/exponential.rs
index 461b9e8..dc16dd9 100644
--- a/src/distributions/exponential.rs
+++ b/src/distributions/exponential.rs
@@ -27,7 +27,7 @@
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct Exp1(pub f64);
// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
@@ -64,7 +64,7 @@
/// let v = exp.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a Exp(2) distribution", v);
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct Exp {
/// `lambda` stored as `1/lambda`, since this is what we scale by.
lambda_inverse: f64
diff --git a/src/distributions/gamma.rs b/src/distributions/gamma.rs
index a0bae49..0cb9fdf 100644
--- a/src/distributions/gamma.rs
+++ b/src/distributions/gamma.rs
@@ -49,12 +49,12 @@
/// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
/// (September 2000),
/// 363-372. DOI:[10.1145/358407.358414](http://doi.acm.org/10.1145/358407.358414)
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct Gamma {
repr: GammaRepr,
}
-#[derive(Copy)]
+#[derive(Clone, Copy)]
enum GammaRepr {
Large(GammaLargeShape),
One(Exp),
@@ -75,7 +75,7 @@
///
/// See `Gamma` for sampling from a Gamma distribution with general
/// shape parameters.
-#[derive(Copy)]
+#[derive(Clone, Copy)]
struct GammaSmallShape {
inv_shape: f64,
large_shape: GammaLargeShape
@@ -85,7 +85,7 @@
///
/// See `Gamma` for sampling from a Gamma distribution with general
/// shape parameters.
-#[derive(Copy)]
+#[derive(Clone, Copy)]
struct GammaLargeShape {
scale: f64,
c: f64,
@@ -194,12 +194,12 @@
/// let v = chi.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a χ²(11) distribution", v)
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct ChiSquared {
repr: ChiSquaredRepr,
}
-#[derive(Copy)]
+#[derive(Clone, Copy)]
enum ChiSquaredRepr {
// k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1,
// e.g. when alpha = 1/2 as it would be for this case, so special-
@@ -252,7 +252,7 @@
/// let v = f.ind_sample(&mut rand::thread_rng());
/// println!("{} is from an F(2, 32) distribution", v)
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct FisherF {
numer: ChiSquared,
denom: ChiSquared,
@@ -296,7 +296,7 @@
/// let v = t.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a t(11) distribution", v)
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct StudentT {
chi: ChiSquared,
dof: f64
diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs
index ae101be..e3b8e0f 100644
--- a/src/distributions/mod.rs
+++ b/src/distributions/mod.rs
@@ -59,6 +59,9 @@
}
impl<Sup> Copy for RandSample<Sup> {}
+impl<Sup> Clone for RandSample<Sup> {
+ fn clone(&self) -> Self { *self }
+}
impl<Sup: Rand> Sample<Sup> for RandSample<Sup> {
fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) }
diff --git a/src/distributions/normal.rs b/src/distributions/normal.rs
index ad874e4..e35cba2 100644
--- a/src/distributions/normal.rs
+++ b/src/distributions/normal.rs
@@ -26,7 +26,7 @@
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct StandardNormal(pub f64);
impl Rand for StandardNormal {
@@ -81,7 +81,7 @@
/// let v = normal.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a N(2, 9) distribution", v)
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct Normal {
mean: f64,
std_dev: f64,
@@ -128,7 +128,7 @@
/// let v = log_normal.ind_sample(&mut rand::thread_rng());
/// println!("{} is from an ln N(2, 9) distribution", v)
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct LogNormal {
norm: Normal
}
diff --git a/src/distributions/range.rs b/src/distributions/range.rs
index 4eee786..6f8bc7a 100644
--- a/src/distributions/range.rs
+++ b/src/distributions/range.rs
@@ -46,7 +46,7 @@
/// println!("{}", sum);
/// }
/// ```
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct Range<X> {
low: X,
range: X,
diff --git a/src/reseeding.rs b/src/reseeding.rs
index af09f8f..e7e36c9 100644
--- a/src/reseeding.rs
+++ b/src/reseeding.rs
@@ -132,7 +132,7 @@
/// Reseed an RNG using a `Default` instance. This reseeds by
/// replacing the RNG with the result of a `Default::default` call.
-#[derive(Copy)]
+#[derive(Clone, Copy)]
pub struct ReseedWithDefault;
impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {