Expand description

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

As an example of using these combinators:

use std::fmt;
use gazebo::display::*;

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

impl fmt::Display for MyItems {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        display_container(f, "{", "}",
            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.

Functions

Chain two iterators together that produce Display items.
Helper for display implementation of container-y types (like list, tuple).
Helper for display implementation of container-y types (like dict, struct).
Display a pair of elements with a separator in the middle.