diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs index 1d0e4576c11..26e05456da3 100644 --- a/src/distributions/mod.rs +++ b/src/distributions/mod.rs @@ -63,6 +63,17 @@ impl RandDistribution { } } +pub struct ConstantDistribution(pub T); + +impl Distribution for ConstantDistribution { + type Output = T; + + fn sample(&self, _: &mut R) -> T { + let ConstantDistribution(ref value) = *self; + value.clone() + } +} + /// A value with a particular weight for use with `WeightedChoice`. pub struct Weighted { /// The numerical weight of this item