From 8eb6336f5e0f5d3d7158e929a167e693f211b991 Mon Sep 17 00:00:00 2001 From: Florian Dehau Date: Sun, 1 Aug 2021 15:01:38 +0200 Subject: [PATCH] refactor(widgets): remove iter::repeat for blank symbols --- src/widgets/list.rs | 5 +---- src/widgets/table.rs | 9 ++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/widgets/list.rs b/src/widgets/list.rs index 064a7b23..d2fc3b17 100644 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -5,7 +5,6 @@ use crate::{ text::Text, widgets::{Block, StatefulWidget, Widget}, }; -use std::iter::{self, Iterator}; use unicode_width::UnicodeWidthStr; #[derive(Debug, Clone)] @@ -185,9 +184,7 @@ impl<'a> StatefulWidget for List<'a> { state.offset = start; let highlight_symbol = self.highlight_symbol.unwrap_or(""); - let blank_symbol = iter::repeat(" ") - .take(highlight_symbol.width()) - .collect::(); + let blank_symbol = " ".repeat(highlight_symbol.width()); let mut current_height = 0; let has_selection = state.selected.is_some(); diff --git a/src/widgets/table.rs b/src/widgets/table.rs index 04b8437d..b45eeb04 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -10,10 +10,7 @@ use cassowary::{ WeightedRelation::*, {Expression, Solver}, }; -use std::{ - collections::HashMap, - iter::{self, Iterator}, -}; +use std::collections::HashMap; use unicode_width::UnicodeWidthStr; /// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`]. @@ -427,9 +424,7 @@ impl<'a> StatefulWidget for Table<'a> { let has_selection = state.selected.is_some(); let columns_widths = self.get_columns_widths(table_area.width, has_selection); let highlight_symbol = self.highlight_symbol.unwrap_or(""); - let blank_symbol = iter::repeat(" ") - .take(highlight_symbol.width()) - .collect::(); + let blank_symbol = " ".repeat(highlight_symbol.width()); let mut current_height = 0; let mut rows_height = table_area.height;