| 1092 |
1092 |
|
}
|
| 1093 |
1093 |
|
|
| 1094 |
1094 |
|
impl RowPart {
|
|
1095 |
+ |
/// What the part is worth when the run does not fit.
|
|
1096 |
+ |
///
|
|
1097 |
+ |
/// The default only. A part may say otherwise, and a renderer reads the
|
|
1098 |
+ |
/// part rather than the role; this is what a description that has never
|
|
1099 |
+ |
/// heard of [`Priority`] means, which is every description written before
|
|
1100 |
+ |
/// the field existed.
|
|
1101 |
+ |
///
|
|
1102 |
+ |
/// Deriving it from the role is the thing this vocabulary has otherwise
|
|
1103 |
+ |
/// been moving away from, and it is right here for one reason: the roles
|
|
1104 |
+ |
/// already encode this ranking and every consumer already assumes it.
|
|
1105 |
+ |
/// [`Primary`](Self::Primary) is what the row is called, and
|
|
1106 |
+ |
/// [`Priority::Essential`]'s own doc was written about exactly that --
|
|
1107 |
+ |
/// "without it the row does not identify itself".
|
|
1108 |
+ |
///
|
|
1109 |
+ |
/// [`Actions`](Self::Actions) is `Essential` and it is the interesting one.
|
|
1110 |
+ |
/// A control is not a fact, so dropping it does not cost the reader a
|
|
1111 |
+ |
/// detail; it costs them the only way to act on the row, and in a terminal
|
|
1112 |
+ |
/// it silently removes something focus had already been claimed for. A
|
|
1113 |
+ |
/// renderer that needs room takes it from what the row *says*, never from
|
|
1114 |
+ |
/// what it *offers*.
|
|
1115 |
+ |
///
|
|
1116 |
+ |
/// An unknown member reads as [`Priority::Secondary`]: droppable, but not
|
|
1117 |
+ |
/// first, since guessing `Optional` for something this crate has not been
|
|
1118 |
+ |
/// taught would make a new member the first thing to vanish.
|
|
1119 |
+ |
#[must_use]
|
|
1120 |
+ |
pub const fn priority(self) -> Priority {
|
|
1121 |
+ |
match self {
|
|
1122 |
+ |
Self::Primary | Self::Actions => Priority::Essential,
|
|
1123 |
+ |
Self::Meta | Self::Proportion => Priority::Optional,
|
|
1124 |
+ |
_ => Priority::Secondary,
|
|
1125 |
+ |
}
|
|
1126 |
+ |
}
|
|
1127 |
+ |
|
| 1095 |
1128 |
|
/// The content intent the part takes.
|
| 1096 |
1129 |
|
#[must_use]
|
| 1097 |
1130 |
|
pub const fn intent(self) -> &'static str {
|
| 5056 |
5089 |
|
assert_eq!(Paging::more(500).of(400).remaining(), Some(0));
|
| 5057 |
5090 |
|
}
|
| 5058 |
5091 |
|
|
|
5092 |
+ |
#[test]
|
|
5093 |
+ |
fn a_role_says_what_a_part_is_worth_when_the_run_does_not_fit() {
|
|
5094 |
+ |
// The row still identifies itself after everything droppable has gone,
|
|
5095 |
+ |
// which is the property the ladder exists for.
|
|
5096 |
+ |
assert_eq!(RowPart::Primary.priority(), Priority::Essential);
|
|
5097 |
+ |
// A control is not a fact. Room comes out of what the row says, never
|
|
5098 |
+ |
// out of what it offers.
|
|
5099 |
+ |
assert_eq!(RowPart::Actions.priority(), Priority::Essential);
|
|
5100 |
+ |
assert_eq!(RowPart::Meta.priority(), Priority::Optional);
|
|
5101 |
+ |
assert_eq!(RowPart::Proportion.priority(), Priority::Optional);
|
|
5102 |
+ |
assert_eq!(RowPart::Secondary.priority(), Priority::Secondary);
|
|
5103 |
+ |
// Tokens sit in the middle deliberately: a toned badge is often the
|
|
5104 |
+ |
// most scannable thing in a row, so it does not go first.
|
|
5105 |
+ |
assert_eq!(RowPart::Tokens.priority(), Priority::Secondary);
|
|
5106 |
+ |
}
|
|
5107 |
+ |
|
| 5059 |
5108 |
|
#[test]
|
| 5060 |
5109 |
|
fn a_run_is_one_line_unless_the_description_says_two() {
|
| 5061 |
5110 |
|
// The default is what every part did before flows existed, so a
|