Trait ValueExt

pub trait ValueExt {
    // Required method
    fn sci(&self, precision: usize, exp_pad: usize) -> String;
}
Expand description

Extends primitives with more specific formatting options

Required Methods§

fn sci(&self, precision: usize, exp_pad: usize) -> String

Better scientific number formatting

The default is not very consistent for scientific in particular, so this allows easy definition.

Works for anything that can be represented as scientific using the LowerExp trait, which is pretty much every numerical primitive.

let number = -1.0;
assert_eq!(number.sci(5, 2), "-1.00000e+00".to_string());
assert_eq!((1.0).sci(5, 2), "1.00000e+00".to_string());

Implementors§

§

impl<T: LowerExp> ValueExt for T