We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ConstantDistribution
1 parent 6e30259 commit c73ab02Copy full SHA for c73ab02
src/distributions/mod.rs
@@ -63,6 +63,17 @@ impl<T> RandDistribution<T> {
63
}
64
65
66
+pub struct ConstantDistribution<T>(pub T);
67
+
68
+impl<T: Clone> Distribution for ConstantDistribution<T> {
69
+ type Output = T;
70
71
+ fn sample<R: Rng>(&self, _: &mut R) -> T {
72
+ let ConstantDistribution(ref value) = *self;
73
+ value.clone()
74
+ }
75
+}
76
77
/// A value with a particular weight for use with `WeightedChoice`.
78
pub struct Weighted<T> {
79
/// The numerical weight of this item
0 commit comments