Hello everyone,
I'm quite new to Rust programming so I hope this is not a dumb question. I want to make a struct with a function that samples random numbers from a uniform distribution. To avoid having to create the distribution every time, I am trying to store it in a variable like so:
impl StructWithDistribution {
fn new() -> StructWithDistribution {
dist: Uniform::from(0..7);
}
}
The struct has more fields, but I have omitted these for now. What I can't figure out is how I should define the type of dist. When I try
pub struct StructWithDistribution {
dist: Uniform
}
I get the error expected 1 generic argument
. I have also tried dist: Uniform<usize>
, but that gives the error expected type
, pointing to the 0 in dist: Uniform::from(0..7)
.
Anyone any idea? Thanks in advance for the help!