Faster, more flexible and more correct alternative to core::fmt (AKA std::fmt)
This is WIP. Some APIs may change, some may lack documentation, others may be broken. Information in this README (especially benchmarks) may be misleading. Contributions are highly appreciated!
I don't promise to work on this much for a while!
size_hint allows writers to e.g. pre-allocate large enough buffer.Write allows to optimize-out error checks.Instead of multiple traits like Display, Debug, ... this crate defines single Fmt<S> which allows you to implement multiple different strategies, even your own. One possible use case is to implement Fmt<Localizer> to enable localization of your application.
Instead of returning Err(()) on failed writes it returns apropriate types. It can even be Void to represent writers that can never fail (e.g. std::string::String).
The crate provides a very simple benchmark:
test bench::bench_core_fmt ... bench: 122 ns/iter (+/- 24)
test bench::bench_fast_fmt ... bench: 26 ns/iter (+/- 1)
It's consistently more than four times faster!
Roughly sorted by priority.
core does. Fmt for primitives)core::fmtT: Iterator<char> + Clone?genio and provide encoders for different encodings.corecore::fmtLast two are jokes.