diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2025-01-22 20:35:06 +0200 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2025-01-22 20:35:06 +0200 |
commit | 7743b25ecb7a2236d7598418a4636ef027a95bc0 (patch) | |
tree | 5bcefbc445615227d01ca1c7ba5ffaaf5925ff4f | |
parent | fcf4d05b8a0b72395f1f6fd8773b4094594120be (diff) | |
download | matrix-rs-7743b25ecb7a2236d7598418a4636ef027a95bc0.tar.gz matrix-rs-7743b25ecb7a2236d7598418a4636ef027a95bc0.tar.bz2 matrix-rs-7743b25ecb7a2236d7598418a4636ef027a95bc0.zip |
chore(cargo): convert project to lib
now the project is called libmatrix
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 25 | ||||
-rw-r--r-- | src/tests/matrix_test.rs | 2 |
4 files changed, 12 insertions, 27 deletions
@@ -2,5 +2,7 @@ name = "matrix-rs" version = "0.1.0" edition = "2021" - +[lib] +name = "matrix" +path = "src/lib.rs" [dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..afe3b75 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,8 @@ +mod types; + +#[cfg(test)] +mod tests; + +pub fn test() { + println!("Testing code here"); +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 0b7000d..0000000 --- a/src/main.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::{error::Error, io::stdin, str::FromStr}; - -#[cfg(test)] -mod tests; - -use types::{matrix::Matrix, matrix_err::ParseMatrixError}; - -mod types; -fn handle_input() -> Result<Matrix, ParseMatrixError> { - let input = stdin(); - let mut construct_string = String::from(""); - loop { - let mut s = "".to_string(); - let _ = input.read_line(&mut s); - if s == "exit\n" { - break; - } - construct_string += &s; - } - Matrix::from_str(construct_string.trim_end()) -} -fn main() -> Result<(), Box<dyn Error>> { - let m = handle_input()?; - Ok(println!("The matrix is:\n{}", m)) -} diff --git a/src/tests/matrix_test.rs b/src/tests/matrix_test.rs index 7a7461a..08ed3a6 100644 --- a/src/tests/matrix_test.rs +++ b/src/tests/matrix_test.rs @@ -1,4 +1,4 @@ -use std::{error::Error, str::FromStr}; +use std::str::FromStr; use crate::types::{matrix::Matrix, matrix_err::ParseMatrixError}; |