blueprint-display-container 0.9.0

Utilities to implement Display
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented1 out of 6 items with examples
  • Size
  • Source code size: 12.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexchoi0

Provides utilities to implement Display, which also provides an "alternate" display.

As an example of using these combinators:

use std::fmt;

use blueprint_display_container::*;

struct MyItems(Vec<(String, i32)>);

impl fmt::Display for MyItems {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt_container(
            f,
            "{",
            "}",
            iter_display_chain(
                &["magic"],
                self.0.iter().map(|(k, v)| display_pair(k, "=", v)),
            ),
        )
    }
}

Would produce results such as:

{magic, hello=1, world=2}

For "normal" display, produces output like (with prefix="prefix[", suffix="]"):

prefix[] prefix[1] prefix[1, 2]

For "alternate" display, produces output like:

prefix[] prefix[ 1 ]

prefix[
  1,
  2
]

This doesn't propagate the flags on the Formatter other than alternate.