1 unstable release

0.9.0 Jun 5, 2023

#21 in #produce

Download history 1382/week @ 2024-09-01 1629/week @ 2024-09-08 1216/week @ 2024-09-15 5010/week @ 2024-09-22 17993/week @ 2024-09-29 2995/week @ 2024-10-06 1721/week @ 2024-10-13 2614/week @ 2024-10-20 2712/week @ 2024-10-27 2942/week @ 2024-11-03 1145/week @ 2024-11-10 2473/week @ 2024-11-17 1793/week @ 2024-11-24 6062/week @ 2024-12-01 3818/week @ 2024-12-08 3538/week @ 2024-12-15

15,367 downloads per month
Used in 7 crates (via starlark)

MIT/Apache

12KB
215 lines

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

As an example of using these combinators:

use std::fmt;
use 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.

Dependencies

~65KB