chore: aggressive linting, with rust v1.65.0
This commit is contained in:
@@ -93,16 +93,11 @@ impl<T> StatefulList<T> {
|
|||||||
|
|
||||||
pub fn previous(&mut self) {
|
pub fn previous(&mut self) {
|
||||||
if !self.items.is_empty() {
|
if !self.items.is_empty() {
|
||||||
let i = match self.state.selected() {
|
let i = self.state.selected().map_or(0, |i| if i == 0 {
|
||||||
Some(i) => {
|
|
||||||
if i == 0 {
|
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
i - 1
|
i - 1
|
||||||
}
|
});
|
||||||
}
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
self.state.select(Some(i));
|
self.state.select(Some(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,18 +398,12 @@ impl ContainerItem {
|
|||||||
|
|
||||||
/// Find the max value in the cpu stats VecDeque
|
/// Find the max value in the cpu stats VecDeque
|
||||||
fn max_cpu_stats(&self) -> CpuStats {
|
fn max_cpu_stats(&self) -> CpuStats {
|
||||||
match self.cpu_stats.iter().max() {
|
self.cpu_stats.iter().max().map_or_else(CpuStats::default, |value| *value)
|
||||||
Some(value) => *value,
|
|
||||||
None => CpuStats::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the max value in the mem stats VecDeque
|
/// Find the max value in the mem stats VecDeque
|
||||||
fn max_mem_stats(&self) -> ByteStats {
|
fn max_mem_stats(&self) -> ByteStats {
|
||||||
match self.mem_stats.iter().max() {
|
self.mem_stats.iter().max().map_or_else(ByteStats::default, |value| *value)
|
||||||
Some(value) => *value,
|
|
||||||
None => ByteStats::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert cpu stats into a vec for the charts function
|
/// Convert cpu stats into a vec for the charts function
|
||||||
|
|||||||
+5
-5
@@ -258,7 +258,7 @@ impl AppData {
|
|||||||
/// 2) "logs - container_name" when no logs found, again 32 chars max
|
/// 2) "logs - container_name" when no logs found, again 32 chars max
|
||||||
pub fn get_log_title(&self) -> String {
|
pub fn get_log_title(&self) -> String {
|
||||||
self.get_selected_log_index()
|
self.get_selected_log_index()
|
||||||
.map_or("".to_owned(), |index| {
|
.map_or(String::new(), |index| {
|
||||||
let logs_len = self.containers.items[index].logs.get_state_title();
|
let logs_len = self.containers.items[index].logs.get_state_title();
|
||||||
let mut name = self.containers.items[index].name.clone();
|
let mut name = self.containers.items[index].name.clone();
|
||||||
name.truncate(32);
|
name.truncate(32);
|
||||||
@@ -454,8 +454,8 @@ impl AppData {
|
|||||||
|
|
||||||
for i in all_containers {
|
for i in all_containers {
|
||||||
if let Some(id) = i.id.as_ref() {
|
if let Some(id) = i.id.as_ref() {
|
||||||
let name = i.names.as_mut().map_or("".to_owned(), |names| {
|
let name = i.names.as_mut().map_or(String::new(), |names| {
|
||||||
names.first_mut().map_or("".to_owned(), |f| {
|
names.first_mut().map_or(String::new(), |f| {
|
||||||
if f.starts_with('/') {
|
if f.starts_with('/') {
|
||||||
f.remove(0);
|
f.remove(0);
|
||||||
}
|
}
|
||||||
@@ -464,12 +464,12 @@ impl AppData {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let state = State::from(i.state.as_ref().map_or("dead".to_owned(), trim_owned));
|
let state = State::from(i.state.as_ref().map_or("dead".to_owned(), trim_owned));
|
||||||
let status = i.status.as_ref().map_or("".to_owned(), trim_owned);
|
let status = i.status.as_ref().map_or(String::new(), trim_owned);
|
||||||
|
|
||||||
let image = i
|
let image = i
|
||||||
.image
|
.image
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or("".to_owned(), std::clone::Clone::clone);
|
.map_or(String::new(), std::clone::Clone::clone);
|
||||||
|
|
||||||
let id = ContainerId::from(id);
|
let id = ContainerId::from(id);
|
||||||
// If container info already in containers Vec, then just update details
|
// If container info already in containers Vec, then just update details
|
||||||
|
|||||||
Reference in New Issue
Block a user