gondola_core/
random.rs

1//! The following file is part of gaps-online-software and published 
2//! under the GPLv3 license
3
4use rand::Rng;
5use rand::distr::StandardUniform;
6use rand::prelude::Distribution;
7
8/// Random numbers for testing/benchmarking
9pub trait FromRandom {
10  fn from_random() -> Self;
11}
12
13pub fn rand_vec<T>(size : usize) -> Vec<T> 
14  where StandardUniform: Distribution<T> {
15  let mut rng = rand::rng();
16
17  let mut random_vector: Vec<T> = Vec::new();
18  for _ in 0..size {
19    let random_number = rng.random::<T>();
20    random_vector.push(random_number);
21  }
22  return random_vector;
23}