Expand description
Libc s(n)printf clone written in Rust, so you can use printf-style formatting without a libc (e.g. in WebAssembly).
Note: You’re probably better off using standard Rust string formatting instead of thie crate unless you specificaly need printf compatibility.
It follows the standard C semantics, except:
- Locale-aware UNIX extensions (
'
and GNU’sI
) are not supported. %a
/%A
(hexadecimal floating point) are currently not implemented.- Length modifiers (
h
,l
, etc.) are checked, but ignored. The passed type is used instead.
Usage example:
use sprintf::sprintf;
let s = sprintf!("%d + %d = %d\n", 3, 9, 3+9).unwrap();
assert_eq!(s, "3 + 9 = 12\n");
The types of the arguments are checked at runtime.
Modules§
- Parse printf format strings
Macros§
- Format a string. (Roughly equivalent to
snprintf
orasprintf
in C)
Enums§
- Error type
Traits§
- Trait for types that can be formatted using printf strings
Functions§
- Format a string. (Roughly equivalent to
vsnprintf
orvasprintf
in C) - Format a string using
parser::FormatElement
s