Expand description
Size-optimized versions of the standard library’s write! and writeln! macros
§Why use these macros?
In code size-constrained systems that perform string formatting,
using the write! or writeln! macro can generate larger code
than writing the contents directly, even after linking and inlining.
The write! and writeln! macros provided by this crate detect when
the write could be optimized as a direct write with write_str
(for fmt::Write) or write (for io::Write) and calls that instead of
format_args! and write_fmt.
§The std feature
By default, this crate is #![no_std] and only supports fmt::Write.
To write to io::Write sinks, enable the std feature.
§Known drawbacks
These macros:
- Target a
write_strmethod on the trait, using an internal adapter to exposewrite_stronio::Write. - Do not currently accept
concat!in the format string. - Do not optimize nested
format_args!likewrite!(w, "{}", format_args!("x")).
Macros§
- branch_
on_ format_ capture - Accepts two macro specifications and a set of
format_args!arguments and conditionally expands based on whether theformat_args!specifies any arguments to format. - write
- An optimizing version of
core::write!that callswrite_str/writewhen possible. - writeln
- An optimizing version of
core::writeln!that callswrite_str/writewhen possible.