Fixed zeroes being trimmed for non-rug numbers

This commit is contained in:
bakk 2021-05-15 16:15:25 +02:00
parent aefdb59882
commit 4912e34ec6
3 changed files with 11 additions and 7 deletions

2
Cargo.lock generated
View File

@ -127,7 +127,7 @@ dependencies = [
[[package]] [[package]]
name = "kalk" name = "kalk"
version = "1.4.3" version = "1.4.4"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"regex", "regex",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kalk" name = "kalk"
version = "1.4.3" version = "1.4.4"
authors = ["PaddiM8"] authors = ["PaddiM8"]
edition = "2018" edition = "2018"
readme = "README.md" readme = "README.md"

View File

@ -51,11 +51,15 @@ impl KalkNum {
#[wasm_bindgen(js_name = toString)] #[wasm_bindgen(js_name = toString)]
pub fn to_string(&self) -> String { pub fn to_string(&self) -> String {
self.value let string_value = self.value.to_string();
.to_string() if string_value.contains(".") {
.trim_end_matches('0') string_value
.trim_end_matches('.') .trim_end_matches('0')
.to_string() .trim_end_matches('.')
.to_string()
} else {
string_value
}
} }
#[wasm_bindgen(js_name = toStringBig)] #[wasm_bindgen(js_name = toStringBig)]