refactor: String::from("") > String::new()

This commit is contained in:
Jack Wills
2022-10-07 03:04:06 +00:00
parent a77f690a49
commit 62fb224786
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ impl<T> StatefulList<T> {
pub fn get_state_title(&self) -> String { pub fn get_state_title(&self) -> String {
if self.items.is_empty() { if self.items.is_empty() {
String::from("") String::new()
} else { } else {
let len = self.items.len(); let len = self.items.len();
let c = self let c = self
+1 -1
View File
@@ -41,7 +41,7 @@ pub mod log_sanitizer {
/// Remove all ansi formatting from a given string and create tui-rs spans /// Remove all ansi formatting from a given string and create tui-rs spans
pub fn remove_ansi<'a>(input: &str) -> Vec<Spans<'a>> { pub fn remove_ansi<'a>(input: &str) -> Vec<Spans<'a>> {
let mut output = String::from(""); let mut output = String::new();
for i in categorise_text(input) { for i in categorise_text(input) {
output.push_str(i.text); output.push_str(i.text);
} }
+1 -1
View File
@@ -63,7 +63,7 @@ fn generate_block<'a>(
SelectablePanel::Logs => { SelectablePanel::Logs => {
format!(" {} {} ", panel.title(), app_data.lock().get_log_title()) format!(" {} {} ", panel.title(), app_data.lock().get_log_title())
} }
SelectablePanel::Commands => String::from(""), SelectablePanel::Commands => String::new(),
}; };
let mut block = Block::default() let mut block = Block::default()
.borders(Borders::ALL) .borders(Borders::ALL)
+4 -4
View File
@@ -251,22 +251,22 @@ impl GuiState {
self.selected_panel = self.selected_panel.prev(); 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) { pub fn next_loading(&mut self, uuid: Uuid) {
self.loading_icon = self.loading_icon.next(); self.loading_icon = self.loading_icon.next();
self.is_loading.insert(uuid); 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 { pub fn get_loading(&mut self) -> String {
if self.is_loading.is_empty() { if self.is_loading.is_empty() {
String::from(" ") String::new()
} else { } else {
self.loading_icon.to_string() 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) { pub fn remove_loading(&mut self, uuid: Uuid) {
self.is_loading.remove(&uuid); self.is_loading.remove(&uuid);
} }