32 fmt standard library
The fmt module provides lightweight, allocation-efficient printf-style string builders. Unlike io::outf, which writes formatted bytes to an I/O descriptor, fmt functions construct and return an immutable String.
#use fmt32.1 Function catalog
Because Edva has no untyped variadic functions, formatting helpers have explicit, fixed arities optimized for code generation and compiler diagnostic output:
| Function | Signature | Format Placeholders | Description | Example |
|---|---|---|---|---|
fmt::tprintf_s1 |
String, String => String |
%s |
Inserts 1 String value |
fmt::tprintf_s1("lib%s.so", "dva") |
fmt::tprintf_s2 |
String, String, String => String |
%s, %s |
Inserts 2 String values |
fmt::tprintf_s2("%s::%s", "std", "io") |
fmt::tprintf_s3 |
String, String, String, String => String |
%s, %s, %s |
Inserts 3 String values |
fmt::tprintf_s3("%s.%s.%s", "a", "b", "c") |
fmt::tprintf_i1 |
String, Int => String |
%d |
Inserts 1 Int value |
fmt::tprintf_i1("code: %d", 404) |
fmt::tprintf_i2 |
String, Int, Int => String |
%d, %d |
Inserts 2 Int values |
fmt::tprintf_i2("case%d.%d", 4, 2) |
32.2 Behavior and design rules
- Fixed conversions: Each
%character consumes itself and the immediately following format specifier (e.g.sord), replacing it with the next supplied argument. - Buffer freeze: Results are constructed in a local
Builderand frozen in place (+b) into an immutableStringwithout intermediary string materialization. - Stream output: For terminal logging or file writing with
{}placeholders, preferio::outfandio::errf.