Skip to main content

number_with_precision

Function number_with_precision 

Source
pub fn number_with_precision(value: impl Display, precision: usize) -> String
Expand description

Rounds to precision decimals: 3.14159 with 2 becomes 3.14 (Rails’ number_with_precision).

§Examples

assert_eq!(ocre::helpers::number_with_precision(2.46, 1), "2.5");