luau-printf 0.732.0

Luau musl snprintf-compatible narrow byte formatting
Documentation
# luau-printf

Musl `snprintf`-compatible narrow byte formatting for Luau, forked from
[`fish-printf`](https://crates.io/crates/fish-printf).

Licensed under the MIT license.

### Usage

Add the crate dependency:

```toml
luau-printf = "0.732.0"
```

### Notes

luau-printf implements the musl `snprintf` narrow-conversion mechanics used by
Luau over safe Rust byte inputs and output sinks. It supports the following
features:

-   Locale-specific formatting (decimal point, thousands separator, etc.)
-   Honors the current rounding mode.
-   Supports the `%n` modifier using narrow `printf` output counts.

luau-printf does not support positional arguments, such as `printf("%2$d", 1, 2)`.
Wide-character conversions such as `%C`, `%S`, `%lc`, and `%ls` are rejected;
Luau's source formatting paths do not use them.

Integer prefixes like `h`, `l`, or `ll` are recognized for supported integer
conversions, but only used for validating the format string. The size of
integer values is taken from the argument type.

luau-printf returns owned output as `BString`, writes to `std::io::Write`
sinks, and accepts byte-string format strings and `%s` arguments through `BStr`.
These byte slices are treated as bounded C-string views where `snprintf` expects
strings: format parsing and `%s` conversion stop at the first NUL byte.

### Examples

```rust
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, b"1.2346e+05");
```

See the crate documentation for additional examples.