luaur_common/functions/vformat_append.rs
1//! Port of `Luau::vformatAppend` from `Common/src/StringUtils.cpp`.
2//!
3//! **Deviation (documented, behaviorally faithful):** the C++ original is a
4//! `printf`-style `void vformatAppend(std::string& ret, const char* fmt,
5//! va_list args)` built on `vsnprintf`. C `va_list`/varargs have no stable Rust
6//! equivalent, and this crate targets stable + `wasm32`, so the formatting
7//! mechanism is replaced by `core::fmt`: callers pass `core::fmt::Arguments`
8//! (produced by `format_args!`) instead of a `printf` format string plus a
9//! `va_list`. The observable effect — appending formatted text to a string — is
10//! preserved; only the *spelling* of the format moves from `%`-specifiers to
11//! Rust's `{}` at the (eventually translated) call sites.
12
13use alloc::string::String;
14use core::fmt::Write;
15
16#[allow(non_snake_case)]
17pub fn vformatAppend(ret: &mut String, args: core::fmt::Arguments<'_>) {
18 // Writing to a `String` is infallible, so the `Result` is discarded.
19 let _ = ret.write_fmt(args);
20}