This commit is contained in:
parent
3e5a71440e
commit
d1a04b9b0c
@ -9,25 +9,21 @@
|
|||||||
//! use renderer::human;
|
//! use renderer::human;
|
||||||
//!
|
//!
|
||||||
//! // "1.00 k"
|
//! // "1.00 k"
|
||||||
//! let tmpStr = human::Formatter::new()
|
//! let tmpStr = human::Formatter::new().format(1000.0);
|
||||||
//! .format(1000.0);
|
|
||||||
//! # assert_eq!(tmpStr, "1.00 k");
|
//! # assert_eq!(tmpStr, "1.00 k");
|
||||||
//!
|
//!
|
||||||
//! // "1.00 M"
|
//! // "1.00 M"
|
||||||
//! let tmpStr2 = human::Formatter::new()
|
//! let tmpStr2 = human::Formatter::new().format(1000000.0);
|
||||||
//! .format(1000000.0);
|
|
||||||
//! # assert_eq!(tmpStr2, "1.00 M");
|
//! # assert_eq!(tmpStr2, "1.00 M");
|
||||||
//!
|
//!
|
||||||
//! // "1.00 B"
|
//! // "1.00 B"
|
||||||
//! let tmpStr3 = human::Formatter::new()
|
//! let tmpStr3 = human::Formatter::new().format(1000000000.0);
|
||||||
//! .format(1000000000.0);
|
|
||||||
//! # assert_eq!(tmpStr3, "1.00 B");
|
//! # assert_eq!(tmpStr3, "1.00 B");
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! If you are so inspired you can even try playing with units and customizing your `Scales`
|
//! If you are so inspired you can even try playing with units and customizing your `Scales`
|
||||||
//!
|
//!
|
||||||
//! For more examples you should review the examples on github: [tests/demo.rs](https://github.com/BobGneu/human-format-rs/blob/master/tests/demo.rs)
|
//! For more examples you should review the examples on github: [tests/demo.rs](https://github.com/BobGneu/human-format-rs/blob/master/tests/demo.rs)
|
||||||
//!
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct ScaledValue {
|
struct ScaledValue {
|
||||||
@ -130,7 +126,7 @@ impl Formatter {
|
|||||||
|
|
||||||
let magnitude_multiplier = self.scales.get_magnitude_multipler(&suffix);
|
let magnitude_multiplier = self.scales.get_magnitude_multipler(&suffix);
|
||||||
|
|
||||||
(result * magnitude_multiplier)
|
result * magnitude_multiplier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user