Function lexical::to_string_with_options

source ·
pub fn to_string_with_options<N: ToLexicalWithOptions, const FORMAT: u128>(
    n: N,
    options: &N::Options,
) -> String
Expand description

High-level conversion of a number to a string with custom writing options.

  • FORMAT - Packed struct containing the number format.
  • n - Number to convert to string.
  • options - Options to specify number writing.

§Examples

const FORMAT: u128 = lexical::format::STANDARD;
let options = lexical::WriteFloatOptions::builder()
    .trim_floats(true)
    .build()
    .unwrap();
assert_eq!(lexical::to_string_with_options::<_, FORMAT>(0.0, &options), "0");
assert_eq!(lexical::to_string_with_options::<_, FORMAT>(123.456, &options), "123.456");