Skip to main content

sprintf

Macro sprintf 

Source
macro_rules! sprintf {
    (
        $fmt:expr // Format string, as bytes.
        $(, $($arg:expr),*)? // arguments
    ) => { ... };
    (
        => $target:expr, // target string
        $fmt:expr // format string
        $(, $($arg:expr),*)? // arguments
    ) => { ... };
}
Expand description

A macro to format a byte string with C-locale formatting rules.

ยงExamples

use luau_printf::sprintf;

// Create a `BString` from a format string.
let s = sprintf!("%0.5g", 123456.0);
assert_eq!(s, "1.2346e+05");

// Write to an existing byte sink.
let mut s = Vec::new();
sprintf!(=> &mut s, "%0.5g", 123456.0);
assert_eq!(s.as_slice(), b"1.2346e+05");