From 62fb22478697cc9a7ab9fb562a724965b437233a Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Fri, 7 Oct 2022 03:04:06 +0000 Subject: [PATCH] refactor: String::from("") > String::new() --- src/app_data/container_state.rs | 2 +- src/ui/color_match.rs | 2 +- src/ui/draw_blocks.rs | 2 +- src/ui/gui_state.rs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app_data/container_state.rs b/src/app_data/container_state.rs index c299de4..b8b32b9 100644 --- a/src/app_data/container_state.rs +++ b/src/app_data/container_state.rs @@ -109,7 +109,7 @@ impl StatefulList { pub fn get_state_title(&self) -> String { if self.items.is_empty() { - String::from("") + String::new() } else { let len = self.items.len(); let c = self diff --git a/src/ui/color_match.rs b/src/ui/color_match.rs index 24d206a..8ad3112 100644 --- a/src/ui/color_match.rs +++ b/src/ui/color_match.rs @@ -41,7 +41,7 @@ pub mod log_sanitizer { /// Remove all ansi formatting from a given string and create tui-rs spans pub fn remove_ansi<'a>(input: &str) -> Vec> { - let mut output = String::from(""); + let mut output = String::new(); for i in categorise_text(input) { output.push_str(i.text); } diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index 0dafee3..50c4177 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -63,7 +63,7 @@ fn generate_block<'a>( SelectablePanel::Logs => { format!(" {} {} ", panel.title(), app_data.lock().get_log_title()) } - SelectablePanel::Commands => String::from(""), + SelectablePanel::Commands => String::new(), }; let mut block = Block::default() .borders(Borders::ALL) diff --git a/src/ui/gui_state.rs b/src/ui/gui_state.rs index b4c586f..f98b990 100644 --- a/src/ui/gui_state.rs +++ b/src/ui/gui_state.rs @@ -251,22 +251,22 @@ impl GuiState { self.selected_panel = self.selected_panel.prev(); } - /// Advance loading animation + /// Insert a new loading_uuid into hashset, and advance the animation by one frame pub fn next_loading(&mut self, uuid: Uuid) { self.loading_icon = self.loading_icon.next(); self.is_loading.insert(uuid); } - /// if is_loading, return loading animation frame, else single space + /// If is_loading has any entries, return the current loading_icon, else an emtpy string pub fn get_loading(&mut self) -> String { if self.is_loading.is_empty() { - String::from(" ") + String::new() } else { self.loading_icon.to_string() } } - /// set is_loading to false, but keep animation frame at same state + /// Remove a loading_uuid from the is_loading hashset pub fn remove_loading(&mut self, uuid: Uuid) { self.is_loading.remove(&uuid); }