From ada3fc52f915fdbb8c8238ef90faa6198c02a299 Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Fri, 12 Jun 2020 21:30:03 +0200 Subject: [PATCH] Trimmed end matches of dots in order to avoid numbers such as `1.`. --- Cargo.lock | 4 ++-- kalk/Cargo.toml | 2 +- kalk_cli/Cargo.toml | 4 ++-- kalk_cli/src/output.rs | 6 +++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed7c583..c07dcdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "kalk" -version = "0.1.8" +version = "0.1.9" dependencies = [ "phf", "regex", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "kalk_cli" -version = "0.1.7" +version = "0.1.8" dependencies = [ "ansi_term", "kalk", diff --git a/kalk/Cargo.toml b/kalk/Cargo.toml index 30ea487..1b59064 100644 --- a/kalk/Cargo.toml +++ b/kalk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kalk" -version = "0.1.8" +version = "0.1.9" authors = ["PaddiM8"] edition = "2018" readme = "README.md" diff --git a/kalk_cli/Cargo.toml b/kalk_cli/Cargo.toml index c549117..1f60b81 100644 --- a/kalk_cli/Cargo.toml +++ b/kalk_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kalk_cli" -version = "0.1.7" +version = "0.1.8" authors = ["PaddiM8"] edition = "2018" readme = "../README.md" @@ -11,7 +11,7 @@ keywords = ["math", "calculator", "cli", "command-line"] categories = ["mathematics", "command-line-utilities"] [dependencies] -kalk = { path = "../kalk", version = "^0.1.8" } +kalk = { path = "../kalk", version = "^0.1.9" } rustyline = "6.1.2" ansi_term = "0.12" regex = "1" diff --git a/kalk_cli/src/output.rs b/kalk_cli/src/output.rs index 4dd31f3..25bc363 100644 --- a/kalk_cli/src/output.rs +++ b/kalk_cli/src/output.rs @@ -19,7 +19,11 @@ pub fn eval(parser: &mut parser::Context, input: &str) { format!("0.{}{}", "0".repeat(exp.abs() as usize), digits) } else if use_sci_notation || result.fract() != 0 { // Insert the comma if there are supposed to be decimals. - let mut chars: Vec = digits.trim_end_matches('0').chars().collect(); + let mut chars: Vec = digits + .trim_end_matches('0') + .trim_end_matches('.') + .chars() + .collect(); chars.insert(comma_pos, '.'); chars.into_iter().collect::() } else {