display_buffer 0.1.0

A helper library to make implementing `core::fmt::Display` easier
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented2 out of 7 items with examples
  • Size
  • Source code size: 12.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 379.02 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • bsielski/display_buffer
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bartelsielski

display_buffer

display_buffer is a no_std helper library to make implementing core::fmt::Display easier.

While implementing core::fmt::Display for a new type seems quite easy, it is actually quite complex to support formatting parameters correctly. Fortunately most of this complexity can be avoided by deferring to the implementation for str in the core library. However the naive way of doing this is to create a String using format! which allocates space on the heap. For a lot of types the string representation is not that long and so it could easily be formatted into a buffer on the stack.

For types which can be formatted using a single core::write!, the fmt! helper macro is provided.