pub fn comma() -> Box<Layout>Expand description
Creates a comma character layout.
This is a convenience function for the common case of comma separators in lists, parameter lists, object properties, and other comma-separated structures.
§Returns
A boxed [Layout::Text] containing a comma.
§Examples
use typeset::*;
// Build a list with explicit commas
let list = comp(
text_str("a"),
comp(
comma(),
comp(space(), text_str("b"), false, false),
false, false
),
false, false
);
assert_eq!(format_layout(list, 2, 80), "a, b");use typeset::*;
// More commonly used with joining functions
let items = join_with_commas(vec![
text_str("first"),
text_str("second"),
text_str("third")
]);
assert_eq!(format_layout(items, 2, 80), "first, second, third");