chore(cargo): convert project to lib

now the project is called libmatrix
This commit is contained in:
Zhongheng Liu 2025-01-22 20:35:06 +02:00
commit 7743b25ecb
Signed by: steven
GPG key ID: 805A28B071DAD84B
4 changed files with 12 additions and 27 deletions

View file

@ -2,5 +2,7 @@
name = "matrix-rs" name = "matrix-rs"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[lib]
name = "matrix"
path = "src/lib.rs"
[dependencies] [dependencies]

8
src/lib.rs Normal file
View file

@ -0,0 +1,8 @@
mod types;
#[cfg(test)]
mod tests;
pub fn test() {
println!("Testing code here");
}

View file

@ -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))
}

View file

@ -1,4 +1,4 @@
use std::{error::Error, str::FromStr}; use std::str::FromStr;
use crate::types::{matrix::Matrix, matrix_err::ParseMatrixError}; use crate::types::{matrix::Matrix, matrix_err::ParseMatrixError};