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§

source

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]);
source

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"]);
source

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]);
source

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"]);

Implementations on Foreign Types§

source§

impl MultiSmooth for [f32]

source§

fn round_to_mut(&mut self, decimals: u32)

source§

fn round_to_str(&self, decimals: u32) -> Vec<String>

source§

fn smooth_mut(&mut self)

source§

fn smooth_str(&self) -> Vec<String>

source§

impl MultiSmooth for [f64]

source§

fn round_to_mut(&mut self, decimals: u32)

source§

fn round_to_str(&self, decimals: u32) -> Vec<String>

source§

fn smooth_mut(&mut self)

source§

fn smooth_str(&self) -> Vec<String>

Implementors§