field_list
Aligned key-value field list composed from
Label and Value atoms.struct Component
pub struct ComponentRenders a list of label-value pairs with labels right-padded for column alignment.
Each row is indented by two spaces, with two spaces separating the label and value.
Pre-styled values bypass the default Value styling.
| Field | Type | Description |
|---|---|---|
fields |
Vec<Field> | Rows in insertion order. |
Implements Display.
Component::new
pub fn new() -> SelfCreate an empty field list.
| Parameter | Type | Description |
|---|---|---|
| returns | Self | A list that displays as nothing until fields are added. |
Component::field
pub fn field(self, label: impl Into<String>, value: impl Into<String>) -> SelfAppend a label-value pair.
| Parameter | Type | Description |
|---|---|---|
label |
impl Into<String> | the field name, shown muted |
value |
impl Into<String> | the field value, shown in the config.value style |
| returns | Self | The list with the field added. |
Component::styled_field
pub fn styled_field(self, label: impl Into<String>, value: impl Display) -> SelfAppend a pre-styled label-value pair that bypasses default value styling.
| Parameter | Type | Description |
|---|---|---|
label |
impl Into<String> | the field name, shown muted |
value |
impl Display | the value, rendered now and printed with its own styling |
| returns | Self | The list with the field added. |
struct Field
struct FieldOne row of a field list, kept until display so labels can be aligned.
| Field | Type | Description |
|---|---|---|
label |
String | Label text, padded to the longest label in the list. |
styled |
bool | Whether value is already styled and is printed as is, not in the config.value style. |
value |
String | Value text, or its rendered form for a pre-styled field. |