pub fn bin_str_do<Res>(
    stuff: impl TryInto<f64> + Display + Clone,
    action: impl FnOnce(String) -> Res
) -> Res
Expand description

Applies an action to a pretty string representation of a number.

let mut s = String::new();
str_do(16_504_670, |pretty| s = pretty);
assert_eq!(&s, "16.50M");

str_do(670, |pretty| s = pretty);
assert_eq!(&s, "670");

str_do(1_052_504_670u32, |pretty| s = pretty);
assert_eq!(&s, "1.05G");