Skip to main content

printf_c_locale

Function printf_c_locale 

Source
pub fn printf_c_locale<W: Write + ?Sized>(
    f: &mut W,
    fmt: &BStr,
    args: &mut [Arg<'_>],
) -> Result<usize, Error>
Expand description

Formats a byte string using the provided format specifiers and arguments, using the C locale.

§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 bytes written on success, or an Error.

§Example

use luau_printf::{printf_c_locale, ToArg};

let mut output = Vec::new();
let fmt = luau_printf::BStr::new("%0.5g");
let mut args = [123456.0_f64.to_arg()];

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

assert_eq!(result, Ok(10));
assert_eq!(output.as_slice(), b"1.2346e+05");