Is there a way to hold a generic random number generator in Rust? I'd like a way to write a generic piece of code such as:
use rand::Rng; // 0.7.2
fn main() {
    // Purely random numbers on the interval 0 to 1
    println!("Pure random");
    let mut rng: Box<dyn rand::Rng> = Box::new(rand::thread_rng());
    for i in 0..10 {
        println!("{}", rng.gen::<f64>());
    }
    println!("");
    // On a seed
    *rng = rand::SeedableRng::seed_from_u64(0);
    for i in 0..10 {
        println!("{}", rng.gen::<f64>());
    }
    println!("");
}
The variable rng holds different kinds of random number generators using a seed or otherwise.  However, there's a whole host of errors with this code such as:
error[E0038]: the trait `rand::Rng` cannot be made into an object
 --> src/main.rs:6:18
  |
6 |     let mut rng: Box<dyn rand::Rng> = Box::new(rand::thread_rng());
  |                  ^^^^^^^^^^^^^^^^^^ the trait `rand::Rng` cannot be made into an object
  |
  = note: method `gen` has generic type parameters
  = note: method `gen_range` has generic type parameters
  = note: method `sample` has generic type parameters
  = note: method `fill` has generic type parameters
  = note: method `try_fill` has generic type parameters
As such, what's the correct way to hold a random number generator so that it can be replaced with another? Basically, I would like to generate purely random numbers, but then replace the generator with one using a seed for debugging purposes.
 
    