Skip to content

Commit 106ad0e

Browse files
committed
missing Copy impls for distributions.
1 parent c6f5bf7 commit 106ad0e

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/distributions/gamma.rs

+8
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ use super::{Distribution, Exp};
5151
/// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
5252
/// (September 2000),
5353
/// 363-372. DOI:[10.1145/358407.358414](http://doi.acm.org/10.1145/358407.358414)
54+
#[derive(Copy)]
5455
pub struct Gamma {
5556
repr: GammaRepr,
5657
}
5758

59+
#[derive(Copy)]
5860
enum GammaRepr {
5961
Large(GammaLargeShape),
6062
One(Exp),
@@ -75,6 +77,7 @@ enum GammaRepr {
7577
///
7678
/// See `Gamma` for sampling from a Gamma distribution with general
7779
/// shape parameters.
80+
#[derive(Copy)]
7881
struct GammaSmallShape {
7982
inv_shape: f64,
8083
large_shape: GammaLargeShape
@@ -84,6 +87,7 @@ struct GammaSmallShape {
8487
///
8588
/// See `Gamma` for sampling from a Gamma distribution with general
8689
/// shape parameters.
90+
#[derive(Copy)]
8791
struct GammaLargeShape {
8892
scale: f64,
8993
c: f64,
@@ -182,10 +186,12 @@ impl Distribution<f64> for GammaLargeShape {
182186
/// let v = chi.sample(&mut rand::thread_rng());
183187
/// println!("{} is from a χ²(11) distribution", v)
184188
/// ```
189+
#[derive(Copy)]
185190
pub struct ChiSquared {
186191
repr: ChiSquaredRepr,
187192
}
188193

194+
#[derive(Copy)]
189195
enum ChiSquaredRepr {
190196
// k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1,
191197
// e.g. when alpha = 1/2 as it would be for this case, so special-
@@ -235,6 +241,7 @@ impl Distribution<f64> for ChiSquared {
235241
/// let v = f.sample(&mut rand::thread_rng());
236242
/// println!("{} is from an F(2, 32) distribution", v)
237243
/// ```
244+
#[derive(Copy)]
238245
pub struct FisherF {
239246
numer: ChiSquared,
240247
denom: ChiSquared,
@@ -275,6 +282,7 @@ impl Distribution<f64> for FisherF {
275282
/// let v = t.sample(&mut rand::thread_rng());
276283
/// println!("{} is from a t(11) distribution", v)
277284
/// ```
285+
#[derive(Copy)]
278286
pub struct StudentT {
279287
chi: ChiSquared,
280288
dof: f64

src/distributions/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl <'a, D: Distribution<T>, T> Distribution<T> for &'a D {
5050

5151
/// A wrapper for generating types that implement `Distribution` via the
5252
/// `Rand` trait.
53+
#[derive(Copy)]
5354
pub struct RandDistribution<Sup> {
5455
_marker: marker::PhantomData<fn() -> Sup>,
5556
}
@@ -74,6 +75,8 @@ pub struct Weighted<T> {
7475
pub item: T,
7576
}
7677

78+
impl <T: Copy> Copy for Weighted<T> {}
79+
7780
/// A distribution that selects from a finite collection of weighted items.
7881
///
7982
/// Each item has an associated weight that influences how likely it

src/distributions/range.rs

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub struct Range<X> {
5353
accept_zone: X
5454
}
5555

56+
impl <X: Copy> Copy for Range<X> {}
57+
5658
impl<X: RangeDistribution + PartialOrd> Range<X> {
5759
/// Create a new `Range` instance that samples uniformly from
5860
/// `[low, high)`. Panics if `low >= high`.

0 commit comments

Comments
 (0)