Function group
Source pub fn group<C: Cost>(x: Doc<C>) -> Doc<C>
Expand description
Create a choice between a document and its flattened version.
ยงExample
let doc = text("hello") & nl() & text("world");
assert_eq!(format!("{doc}"), "hello\nworld");
let doc = group(doc);
assert_eq!(format!("{doc}"), "hello world");
assert_eq!(format!("{doc:10}"), "hello\nworld");