|
|
@ -130,13 +130,14 @@ where
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn widths(mut self, widths: &'a [Constraint]) -> Table<'a, T, H, I, D, R> {
|
|
|
|
pub fn widths(mut self, widths: &'a [Constraint]) -> Table<'a, T, H, I, D, R> {
|
|
|
|
|
|
|
|
let between_0_and_100 = |&w| {
|
|
|
|
|
|
|
|
match w {
|
|
|
|
|
|
|
|
Constraint::Percentage(p) => p <= 100,
|
|
|
|
|
|
|
|
_ => true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
assert!(
|
|
|
|
assert!(
|
|
|
|
widths.iter().all(|w| {
|
|
|
|
widths.iter().all(between_0_and_100),
|
|
|
|
match w {
|
|
|
|
|
|
|
|
Constraint::Percentage(p) => *p <= 100,
|
|
|
|
|
|
|
|
_ => true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
"Percentages should be between 0 and 100 inclusively."
|
|
|
|
"Percentages should be between 0 and 100 inclusively."
|
|
|
|
);
|
|
|
|
);
|
|
|
|
self.widths = widths;
|
|
|
|
self.widths = widths;
|
|
|
@ -270,5 +271,4 @@ mod tests {
|
|
|
|
Table::new([""].iter(), vec![Row::Data([""].iter())].into_iter())
|
|
|
|
Table::new([""].iter(), vec![Row::Data([""].iter())].into_iter())
|
|
|
|
.widths(&[Constraint::Percentage(110)]);
|
|
|
|
.widths(&[Constraint::Percentage(110)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|