Make type of Rng generic in function signatures

This commit is contained in:
Joel Therrien 2022-09-16 21:39:54 -07:00
parent cffe7b4f47
commit 031bdf6cd9
2 changed files with 6 additions and 6 deletions

View file

@ -292,8 +292,8 @@ fn run_multi_threaded(
} }
fn get_puzzle_matching_conditions( fn get_puzzle_matching_conditions<R: Rng>(
rng: &mut SmallRng, rng: &mut R,
difficulty: &Difficulty, difficulty: &Difficulty,
solve_controller: &SolveController, solve_controller: &SolveController,
max_hints: u64, max_hints: u64,

View file

@ -8,7 +8,7 @@ use std::rc::Rc;
pub static mut DEBUG: bool = false; pub static mut DEBUG: bool = false;
impl Grid { impl Grid {
fn get_random_empty_cell(&self, rng: &mut SmallRng) -> Result<Rc<Cell>, &str> { fn get_random_empty_cell<R: Rng>(&self, rng: &mut R) -> Result<Rc<Cell>, &str> {
// Idea - put all empty cells into a vector and choose one at random // Idea - put all empty cells into a vector and choose one at random
// If vector is empty we return an error // If vector is empty we return an error
@ -125,8 +125,8 @@ impl Section {
} }
} }
pub fn generate_grid( pub fn generate_grid<R: Rng>(
rng: &mut SmallRng, rng: &mut R,
solve_controller: &SolveController, solve_controller: &SolveController,
) -> (Grid, u64, SolveStatistics) { ) -> (Grid, u64, SolveStatistics) {
let mut grid = generate_completed_grid(rng); let mut grid = generate_completed_grid(rng);
@ -179,7 +179,7 @@ pub fn generate_grid(
} }
// We generate a completed grid with no mind for difficulty; afterward generate_puzzle will take out as many fields as it can with regards to the difficulty // We generate a completed grid with no mind for difficulty; afterward generate_puzzle will take out as many fields as it can with regards to the difficulty
fn generate_completed_grid(rng: &mut SmallRng) -> Grid { fn generate_completed_grid<R: Rng>(rng: &mut R) -> Grid {
let solve_controller = SolveController { let solve_controller = SolveController {
determine_uniqueness: true, determine_uniqueness: true,
search_singles: true, search_singles: true,