Преглед на файлове

Silenced warnings in "working on" code.

Steve Thielemann преди 1 месец
родител
ревизия
b9e43ad1bd
променени са 2 файла, в които са добавени 24 реда и са изтрити 12 реда
  1. 6 0
      sudoku/src/bits.rs
  2. 18 12
      sudoku/src/sudoku.rs

+ 6 - 0
sudoku/src/bits.rs

@@ -126,6 +126,12 @@ impl fmt::Debug for GenBits {
         }
 }
 
+impl fmt::Display for GenBits {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "({})", self.0.iter().enumerate().filter(|x| *x.1).map(|x| x.0.to_string()).collect::<Vec<_>>().join(","))
+    }
+}
+
 impl PartialEq for GenBits {
     fn eq(&self, other: &Self) -> bool {
         if self.0.len() != other.0.len() {

+ 18 - 12
sudoku/src/sudoku.rs

@@ -870,7 +870,7 @@ impl AnySolver {
         // I might want to save the pair information.
 
         for cell in 0..width {
-            self.possible
+            let _ = self.possible
                 .find_pairs(self.group.group(Groups::Cell, cell));
         }
 
@@ -878,9 +878,9 @@ impl AnySolver {
 
         // Scan rows/columns
         for cell in 0..width {
-            let cell_info = self.group.group(Groups::Cell, cell);
+            let _cell_info = self.group.group(Groups::Cell, cell);
 
-            for row in 0..size {}
+            for _row in 0..size {}
         }
     }
 
@@ -901,7 +901,9 @@ impl AnySolver {
         cell_update[cell_index as usize] = true;
 
         let values = self.possible.find_value_pos();
-        println!("Values: {:?}", values);
+
+        // Not needed, displayed below (and only if not empty). ;)
+        // println!("Values: {:?}", values);
 
         for (value, positions) in values.iter().enumerate() {
             if positions.count_set() == 0 {
@@ -916,7 +918,7 @@ impl AnySolver {
                 cell_has_value.set(p, true); // [p as usize] = true;
             }
 
-            println!("Value {} : Pos {:?}", value, cell_has_value);
+            println!("Value {} : Pos {}", value, cell_has_value);
 
             // cell_has_value gives me the indexes that contain value.
             // I need to process cell rows/columns...
@@ -931,7 +933,7 @@ impl AnySolver {
                 }
 
                 // rows go the entire width of the game...
-                for row in 0..width {}
+                for _row in 0..width {}
             }
         }
         /*
@@ -1059,8 +1061,8 @@ impl AnySolver {
 
             // println!("Value {} {:?} is needed {:?}", value + 1, all_cells, found);
 
-            for x in x_range.clone() {
-                for y in 0..width {
+            for _x in x_range.clone() {
+                for _y in 0..width {
                     // Calculate the row and column for the given cell.
                     // let _col = (cell_index % width) * width + c;
                     // println!("Index {} COL {}", index, col);
@@ -1069,9 +1071,9 @@ impl AnySolver {
         }
 
         // Check rows
-        for value in 0..width {
-            for y in y_range.clone() {
-                for x in 0..width {
+        for _value in 0..width {
+            for _y in y_range.clone() {
+                for _x in 0..width {
                     // Calculate the row and column for the given cell.
                     // let _row = (cell_index / width) * width + r;
                     // println!("Index {} ROW {}", index, row);
@@ -1828,7 +1830,8 @@ mod tests {
         board.set(0, 4, 4);
         board.set(0, 5, 5);
         board.display();
-        let mut solver = AnySolver::new_from(&board);
+        
+        let solver = AnySolver::new_from(&board);
         /*
            ╔═══╦═══╦═══╗
            ║ 2 ║   ║   ║
@@ -2048,6 +2051,9 @@ mod tests {
         // solver.possible.display();
     }
 
+    // Running just this test:
+    // cargo test -p sudoku logic_test_triple -- --ignored --show-output
+
     #[ignore]
     #[test]
     fn logic_test_triple() {