ソースを参照

Sudoku as library.

Bugz 9 ヶ月 前
コミット
9a9521d174
5 ファイル変更35 行追加10 行削除
  1. 15 0
      Cargo.toml
  2. 4 2
      src/main.rs
  3. 12 0
      sudoku/Cargo.toml
  4. 4 5
      sudoku/src/group.rs
  5. 0 3
      sudoku/src/lib.rs

+ 15 - 0
Cargo.toml

@@ -1,3 +1,5 @@
+workspace = { members = ["sudoku"] }
+
 [package]
 name = "sudoku2"
 version = "0.1.0"
@@ -10,3 +12,16 @@ clap = { version = "4.4.18", features = ["derive"] }
 serde = "1.0.196"
 serde-xml-rs = "0.6.0"
 serde_derive = "1.0.196"
+
+# [workspace]
+# [dependencies]
+
+sudoku = { path = "sudoku" }
+
+# [dev-dependencies]
+# criterion = "0.5.1"
+
+# [[bench]]
+# name = "benchmark"
+# harness = false
+

+ 4 - 2
src/main.rs

@@ -11,8 +11,10 @@ use std::fs::File;
 
 // mod group;
 // use crate::group::*;
-mod sudoku;
-use crate::sudoku::*;
+use sudoku::*;
+
+// mod sudoku;
+// use crate::sudoku::*;
 // use crate::sudoku::group::*;
 
 // use crate::group::*;

+ 12 - 0
sudoku/Cargo.toml

@@ -0,0 +1,12 @@
+[package]
+name = "sudoku"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+
+[lib]
+name = "sudoku"
+test = true

+ 4 - 5
src/sudoku/group.rs → sudoku/src/group.rs

@@ -1,9 +1,7 @@
 use std::fmt;
 
-// use super::sudoku::*;
-use crate::sudoku::*;
-// mod sudoku;
-// use crate::sudoku::*;
+// load sudoku
+use crate::*;
 
 /// Width of the sudoku board.
 const WIDTH: u8 = 9;
@@ -422,7 +420,8 @@ pub fn which_cell(x:u8, y:u8) -> u8 {
 
 #[cfg(test)]
 mod tests {
-    use crate::sudoku::group::*;
+    use crate::*;
+    // use crate::sudoku::group::*;
     // use crate::Group;
     // use group::*;
 

+ 0 - 3
src/sudoku.rs → sudoku/src/lib.rs

@@ -1,8 +1,5 @@
 pub mod group;
 use group::*;
-// use crate::group::*;
-// use super::group::*;
-// use crate::group::*;
 
 use std::collections::HashSet;