From 211fc67cf2ed7fe256d3580db1b6edb050d83efb Mon Sep 17 00:00:00 2001 From: erius Date: Thu, 23 May 2024 11:08:52 +0300 Subject: [PATCH] Restructured the project to use cargo workspace, math module is now a separate crate --- Cargo.lock | 2 +- Cargo.toml | 12 +++++------- math/Cargo.toml | 7 +++++++ math/src/lib.rs | 2 ++ {src/math => math/src}/matrix.rs | 2 +- {src/math => math/src}/matrix/arithemtic.rs | 0 {src/math => math/src}/matrix/iter.rs | 0 {src/math => math/src}/matrix/ops.rs | 0 {src/math => math/src}/sq_matrix.rs | 4 +--- src/lib.rs | 1 - src/math.rs | 7 ------- 11 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 math/Cargo.toml create mode 100644 math/src/lib.rs rename {src/math => math/src}/matrix.rs (98%) rename {src/math => math/src}/matrix/arithemtic.rs (100%) rename {src/math => math/src}/matrix/iter.rs (100%) rename {src/math => math/src}/matrix/ops.rs (100%) rename {src/math => math/src}/sq_matrix.rs (93%) delete mode 100644 src/lib.rs delete mode 100644 src/math.rs diff --git a/Cargo.lock b/Cargo.lock index ac37eb0..e858bfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] -name = "mathematical" +name = "math" version = "0.1.0" dependencies = [ "num", diff --git a/Cargo.toml b/Cargo.toml index dd7d7b7..38e3f11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,5 @@ -[package] -name = "mathematical" -version = "0.1.0" -edition = "2021" - -[dependencies] -num = "0.4.3" +[workspace] +resolver = "2" +members = [ + "math" +] diff --git a/math/Cargo.toml b/math/Cargo.toml new file mode 100644 index 0000000..1b3de5c --- /dev/null +++ b/math/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "math" +version = "0.1.0" +edition = "2021" + +[dependencies] +num = "0.4.3" diff --git a/math/src/lib.rs b/math/src/lib.rs new file mode 100644 index 0000000..aecb370 --- /dev/null +++ b/math/src/lib.rs @@ -0,0 +1,2 @@ +pub mod matrix; +pub mod sq_matrix; diff --git a/src/math/matrix.rs b/math/src/matrix.rs similarity index 98% rename from src/math/matrix.rs rename to math/src/matrix.rs index db4852c..b96eb6d 100644 --- a/src/math/matrix.rs +++ b/math/src/matrix.rs @@ -108,7 +108,7 @@ impl IndexMut<(usize, usize)> for Matrix { #[macro_export] macro_rules! matrix { [ $w:expr; $( $x:expr ),+ ] => { - $crate::math::Matrix::new(vec![$( $x, )+], $w) + $crate::matrix::Matrix::new(vec![$( $x, )+], $w) }; } diff --git a/src/math/matrix/arithemtic.rs b/math/src/matrix/arithemtic.rs similarity index 100% rename from src/math/matrix/arithemtic.rs rename to math/src/matrix/arithemtic.rs diff --git a/src/math/matrix/iter.rs b/math/src/matrix/iter.rs similarity index 100% rename from src/math/matrix/iter.rs rename to math/src/matrix/iter.rs diff --git a/src/math/matrix/ops.rs b/math/src/matrix/ops.rs similarity index 100% rename from src/math/matrix/ops.rs rename to math/src/matrix/ops.rs diff --git a/src/math/sq_matrix.rs b/math/src/sq_matrix.rs similarity index 93% rename from src/math/sq_matrix.rs rename to math/src/sq_matrix.rs index c531561..b259b70 100644 --- a/src/math/sq_matrix.rs +++ b/math/src/sq_matrix.rs @@ -45,8 +45,6 @@ fn check_size(order: usize) -> usize { #[macro_export] macro_rules! sq_matrix { [ $o:expr; $( $x:expr ),+ ] => { - $crate::math::SquareMatrix::new(vec![$( $x, )+], $o) + $crate::matrix::SquareMatrix::new(vec![$( $x, )+], $o) }; } - -pub use sq_matrix; diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index b8135c3..0000000 --- a/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod math; diff --git a/src/math.rs b/src/math.rs deleted file mode 100644 index a005381..0000000 --- a/src/math.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod matrix; -pub use matrix::Matrix; -pub use matrix::matrix; - -mod sq_matrix; -pub use sq_matrix::SquareMatrix; -pub use sq_matrix::sq_matrix;