Trait smooth::MultiSmooth
source · pub trait MultiSmooth {
// Required methods
fn round_to_mut(&mut self, decimals: u32);
fn round_to_str(&self, decimals: u32) -> Vec<String>;
fn smooth_mut(&mut self);
fn smooth_str(&self) -> Vec<String>;
}
Expand description
Extension trait to consistently make multiple numbers human-readable.
Required Methods§
sourcefn round_to_mut(&mut self, decimals: u32)
fn round_to_mut(&mut self, decimals: u32)
Rounds all numbers to the specified decimals.
Examples
let mut numbers = [1.1111, 5.5555, 9.9999];
numbers.round_to_mut(2);
assert_eq!(numbers, [1.11, 5.56, 10.0]);
sourcefn round_to_str(&self, decimals: u32) -> Vec<String>
fn round_to_str(&self, decimals: u32) -> Vec<String>
Returns formatted, consistently rounded numbers.
Examples
let numbers = [1.1111, 5.5555, 9.9999];
assert_eq!(numbers.round_to_str(2), ["1.11", "5.56", "10"]);
sourcefn smooth_mut(&mut self)
fn smooth_mut(&mut self)
Consistently smoothes all numbers.
Examples
let mut numbers = [1.1111, 5.5555, 9.9999];
numbers.smooth_mut();
assert_eq!(numbers, [1.1, 5.6, 10.0]);
sourcefn smooth_str(&self) -> Vec<String>
fn smooth_str(&self) -> Vec<String>
Returns formatted, consistently smoothed numbers.
Examples
let numbers = [1.1111, 5.5555, 9.9999];
assert_eq!(numbers.smooth_str(), ["1.1", "5.6", "10"]);