From 56376fa2b8a589261a0e70d412dbbf413ebe4525 Mon Sep 17 00:00:00 2001 From: gbrochar Date: Mon, 15 Jan 2024 13:44:19 +0100 Subject: [PATCH] fix(lib): format and lint --- src/lib.rs | 14 +++++++------- src/maths/solver.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c15f7a5..094f4e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,15 +12,15 @@ pub fn format(v: &[GaussianRational]) -> String { let mut format; format = v[0].format(false); if v.len() > 1 { - let mut format2 = v[1].format(true); - if format2 == "" { - if format == "" { - format = format!("{}x", format2); - } else { - format = format!("{format} + {}x", format2); + let format2 = v[1].format(true); + if format2 != "" { + if format == "" { + format = format!("{}x", format2); + } else { + format = format!("{format} + {}x", format2); + } } } - } for i in 2..v.len() { let tmp = v[i].format(true); if tmp != "" { diff --git a/src/maths/solver.rs b/src/maths/solver.rs index 8eec809..ab44142 100644 --- a/src/maths/solver.rs +++ b/src/maths/solver.rs @@ -13,7 +13,7 @@ fn degree_one(equation: Vec) { println!("Polynomial degree: 1"); let x = minus_one() * equation[0] / equation[1]; println!("The solution is"); - let mut format = x.format(false); + let mut format = crate::format(&[x]); if format == "" { format = String::from("0"); } @@ -398,4 +398,4 @@ pub fn solve(mut equation: Vec) -> Vec { _ => println!("Polynomial of degree greater than 2 detected, I can't solve that !"), } vec![] -} \ No newline at end of file +}