From 978d3ab3f3c7eb9f0b7c3978c5f30c0ff1763fb3 Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Thu, 6 May 2021 19:56:00 -0700 Subject: [PATCH] Run `cargo fmt` --- src/bin/generator.rs | 13 ++++++------- src/generator.rs | 12 +++++++++--- src/pdf.rs | 10 +++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/bin/generator.rs b/src/bin/generator.rs index e7b626a..63f8932 100644 --- a/src/bin/generator.rs +++ b/src/bin/generator.rs @@ -141,12 +141,11 @@ fn main() { "Number of threads to use when generating possible puzzles", ); - ap.refer(&mut print_possibilities) - .add_option( + ap.refer(&mut print_possibilities).add_option( &["-p", "--possibilities"], argparse::StoreTrue, - "Include each cell's possibilities in the output; applies only to PDF output" - ); + "Include each cell's possibilities in the output; applies only to PDF output", + ); ap.parse_args_or_exit(); } @@ -165,7 +164,7 @@ fn main() { max_attempts, max_hints, &AtomicBool::new(false), - debug + debug, ) } else { run_multi_threaded( @@ -260,7 +259,7 @@ fn run_multi_threaded( thread_attempts, max_hints, should_stop, - debug + debug, ); let mut result_was_some = false; @@ -313,7 +312,7 @@ fn get_puzzle_matching_conditions( max_attempts: i32, max_hints: i32, should_stop: &AtomicBool, - debug: bool + debug: bool, ) -> (Option<(Grid, SolveStatistics, i32)>, i32) { let mut num_attempts = 0; diff --git a/src/generator.rs b/src/generator.rs index 9ea10f0..17359f7 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -219,11 +219,17 @@ fn generate_completed_grid(rng: &mut SmallRng) -> Grid { eprintln!("Wow! A puzzle with only 8 guesses have been found"); return grid; } - Uniqueness::NotUnique => {break grid;} // What we expect + Uniqueness::NotUnique => { + break grid; + } // What we expect } } - SolveStatus::Unfinished => {panic!("evaluate_grid_with_solve_controller should never return UNFINISHED if we are making guesses")} - SolveStatus::Invalid => {continue;} // unlucky; try again + SolveStatus::Unfinished => { + panic!("evaluate_grid_with_solve_controller should never return UNFINISHED if we are making guesses") + } + SolveStatus::Invalid => { + continue; + } // unlucky; try again } }; diff --git a/src/pdf.rs b/src/pdf.rs index b8c85d3..a411d8a 100644 --- a/src/pdf.rs +++ b/src/pdf.rs @@ -9,7 +9,11 @@ const GRID_DIMENSION: f64 = 190.0; const A4: (Mm, Mm) = (Mm(215.0), Mm(279.0)); -pub fn draw_grid(grid: &Grid, filename: &str, print_possibilities: bool) -> Result<(), Box> { +pub fn draw_grid( + grid: &Grid, + filename: &str, + print_possibilities: bool, +) -> Result<(), Box> { let (doc, page1, layer1) = PdfDocument::new("Sudoku Puzzle", A4.0, A4.1, "Layer 1"); let layer = doc.get_page(page1).get_layer(layer1); @@ -45,12 +49,12 @@ pub fn draw_grid(grid: &Grid, filename: &str, print_possibilities: bool) -> Resu CellValue::Unknown(possibilities) => { if print_possibilities { for (_, possibility) in possibilities.iter().enumerate() { - let sub_row = (possibility - 1) / 3; let sub_column = (possibility - 1) % 3; // Need to adjust x & y let x = Mm(x.0 - 4.0 + (GRID_DIMENSION / 27.0) * (sub_column as f64)); - let y = Mm(y.0 - 9.5 + (GRID_DIMENSION / 27.0) * (3.0 - sub_row as f64)); + let y = + Mm(y.0 - 9.5 + (GRID_DIMENSION / 27.0) * (3.0 - sub_row as f64)); let text = possibility.to_string(); layer.use_text(text, possibility_font_size, x, y, &font);