Function printf_c_locale

Source
pub fn printf_c_locale(
    f: &mut impl Write,
    fmt: impl FormatString,
    args: &mut [Arg<'_>],
) -> Result<usize, Error>
Expand description

Formats a string using the provided format specifiers and arguments, using the C locale, and writes the output to the given Write implementation.

§Parameters

  • f: The receiver of formatted output.
  • fmt: The format string being parsed.
  • args: Iterator over the arguments to format.

§Returns

A Result which is Ok containing the number of characters written on success, or an Error.

§Example

use fish_printf::{printf_c_locale, ToArg, FormatString};
use std::fmt::Write;

let mut output = String::new();
let fmt: &str = "%0.5g";  // Example format string
let mut args = [123456.0.to_arg()];

let result = printf_c_locale(&mut output, fmt, &mut args);

assert!(result == Ok(10));
assert_eq!(output, "1.2346e+05");