pub fn sprintf_locale(
f: &mut impl Write,
fmt: impl FormatString,
locale: &Locale,
args: &mut [Arg<'_>],
) -> Result<usize, Error>
Expand description
Formats a string using the provided format specifiers, arguments, and locale,
and writes the output to the given Write
implementation.
§Parameters
f
: The receiver of formatted output.fmt
: The format string being parsed.locale
: The locale to use for number formatting.args
: Iterator over the arguments to format.
§Returns
A Result
which is Ok
containing the number of bytes written on success, or an Error
.
§Example
use fish_printf::{sprintf_locale, ToArg, FormatString, locale};
use std::fmt::Write;
let mut output = String::new();
let fmt: &str = "%'0.2f";
let mut args = [1234567.89.to_arg()];
let result = sprintf_locale(&mut output, fmt, &locale::EN_US_LOCALE, &mut args);
assert!(result == Ok(12));
assert_eq!(output, "1,234,567.89");