diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs index 4a51e5c14cc..96cc0f3427d 100644 --- a/src/distributions/mod.rs +++ b/src/distributions/mod.rs @@ -62,6 +62,16 @@ impl RandDistribution { } } +pub struct ConstantDistribution(pub T); + +impl Distribution for ConstantDistribution { + type Output = T; + + fn sample(&self, _: &mut R) -> T { + self.0.clone() + } +} + /// A value with a particular weight for use with `WeightedChoice`. #[derive(Copy)] pub struct Weighted {