-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display usd values rounded to 2 decimal places; bump to 0.3.4
- Loading branch information
Showing
5 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "book-of-profits" | ||
version = "0.3.3" | ||
version = "0.3.4" | ||
edition = "2021" | ||
authors = ["Nuno David <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![allow(dead_code)] | ||
|
||
pub trait ExtendFloat: num_traits::Float { | ||
fn round_to_fixed(&self, decimals: u8) -> Self; | ||
fn round_to_fixed_string(&self, decimals: u8) -> String; | ||
} | ||
|
||
impl ExtendFloat for f64 { | ||
fn round_to_fixed(&self, decimals: u8) -> Self { | ||
let precision = 10.0_f64.powi(decimals as i32); | ||
(self * precision).round() / precision | ||
} | ||
fn round_to_fixed_string(&self, decimals: u8) -> String { | ||
format!("{:.*}", decimals as usize, self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod spinner; | |
pub mod support_option; | ||
pub mod table; | ||
pub mod text; | ||
pub mod float; |