diff --git a/src/buffer.rs b/src/buffer.rs index ffc9037..ee5d74b 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -520,12 +520,8 @@ mod tests { #[test] fn buffer_with_lines() { - let buffer = Buffer::with_lines(vec![ - "┌────────┐", - "│コンピュ│", - "│ーa 上で│", - "└────────┘", - ]); + let buffer = + Buffer::with_lines(vec!["┌────────┐", "│コンピュ│", "│ーa 上で│", "└────────┘"]); assert_eq!(buffer.area.x, 0); assert_eq!(buffer.area.y, 0); assert_eq!(buffer.area.width, 10); @@ -619,11 +615,7 @@ mod tests { let diff = prev.diff(&next); assert_eq!( diff, - vec![ - (1, 0, &cell("─")), - (2, 0, &cell("称")), - (4, 0, &cell("号")), - ] + vec![(1, 0, &cell("─")), (2, 0, &cell("称")), (4, 0, &cell("号")),] ); } diff --git a/src/widgets/table.rs b/src/widgets/table.rs index 03a187e..9776ddf 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -130,13 +130,14 @@ where } 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!( - widths.iter().all(|w| { - match w { - Constraint::Percentage(p) => *p <= 100, - _ => true, - } - }), + widths.iter().all(between_0_and_100), "Percentages should be between 0 and 100 inclusively." ); self.widths = widths; @@ -270,5 +271,4 @@ mod tests { Table::new([""].iter(), vec![Row::Data([""].iter())].into_iter()) .widths(&[Constraint::Percentage(110)]); } - } diff --git a/tests/paragraph.rs b/tests/paragraph.rs index 6f627c4..b4ef4e1 100644 --- a/tests/paragraph.rs +++ b/tests/paragraph.rs @@ -82,8 +82,7 @@ fn paragraph_render_double_width() { let backend = TestBackend::new(10, 10); let mut terminal = Terminal::new(backend).unwrap(); - let s = - "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点では、"; + let s = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点では、"; terminal .draw(|mut f| { let size = f.size();