grouped_list

Headed list molecule with a summary line and pre-rendered rows.

struct Component

source

pub struct Component<'a>

A headed list section with heading, summary, and rows.

Field Type Description
heading &'a str Section heading, in the list.heading style.
rows Vec<String> Pre-rendered rows, printed as is after a blank line.
summary String Text beside the heading, such as a count, in the list.summary style.

Implements Display.

Component::new

source

pub fn new(heading: &'a str, summary: impl Into<String>) -> Self

Create a grouped list with the given heading and summary line.

Parameter Type Description
heading &'a str the section heading
summary impl Into<String> the text shown two spaces after the heading
returns Self The list with no rows.

Component::row

source

pub fn row(self, row: impl Into<String>) -> Self

Add a pre-rendered row to the list.

Parameter Type Description
row impl Into<String> the row text, already styled
returns Self The list with the row appended.