fix(lib): format and lint
This commit is contained in:
parent
ed44fba94f
commit
56376fa2b8
14
src/lib.rs
14
src/lib.rs
|
@ -12,15 +12,15 @@ pub fn format(v: &[GaussianRational]) -> String {
|
||||||
let mut format;
|
let mut format;
|
||||||
format = v[0].format(false);
|
format = v[0].format(false);
|
||||||
if v.len() > 1 {
|
if v.len() > 1 {
|
||||||
let mut format2 = v[1].format(true);
|
let format2 = v[1].format(true);
|
||||||
if format2 == "" {
|
if format2 != "" {
|
||||||
if format == "" {
|
if format == "" {
|
||||||
format = format!("{}x", format2);
|
format = format!("{}x", format2);
|
||||||
} else {
|
} else {
|
||||||
format = format!("{format} + {}x", format2);
|
format = format!("{format} + {}x", format2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for i in 2..v.len() {
|
for i in 2..v.len() {
|
||||||
let tmp = v[i].format(true);
|
let tmp = v[i].format(true);
|
||||||
if tmp != "" {
|
if tmp != "" {
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn degree_one(equation: Vec<GaussianRational>) {
|
||||||
println!("Polynomial degree: 1");
|
println!("Polynomial degree: 1");
|
||||||
let x = minus_one() * equation[0] / equation[1];
|
let x = minus_one() * equation[0] / equation[1];
|
||||||
println!("The solution is");
|
println!("The solution is");
|
||||||
let mut format = x.format(false);
|
let mut format = crate::format(&[x]);
|
||||||
if format == "" {
|
if format == "" {
|
||||||
format = String::from("0");
|
format = String::from("0");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue