refactor: map_or_else to map_or
This commit is contained in:
+6
-6
@@ -70,7 +70,7 @@ impl AppData {
|
|||||||
.state
|
.state
|
||||||
.select(self.containers.items.iter().position(|i| {
|
.select(self.containers.items.iter().position(|i| {
|
||||||
self.get_selected_container_id()
|
self.get_selected_container_id()
|
||||||
.map_or_else(|| false, |id| i.id == id)
|
.map_or(false, |id| i.id == id)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
/// Generate a default app_state
|
/// Generate a default app_state
|
||||||
@@ -259,8 +259,8 @@ impl AppData {
|
|||||||
/// Get the title for log panel for selected container
|
/// Get the title for log panel for selected container
|
||||||
/// will be "logs x/x"
|
/// will be "logs x/x"
|
||||||
pub fn get_log_title(&self) -> String {
|
pub fn get_log_title(&self) -> String {
|
||||||
self.get_selected_log_index().map_or_else(
|
self.get_selected_log_index().map_or(
|
||||||
|| String::from(""),
|
"".to_owned(),
|
||||||
|index| self.containers.items[index].logs.get_state_title(),
|
|index| self.containers.items[index].logs.get_state_title(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ impl AppData {
|
|||||||
if !all_containers
|
if !all_containers
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|i| i.id.as_ref())
|
.filter_map(|i| i.id.as_ref())
|
||||||
.any(|x| &ContainerId::from(x) == id)
|
.any(|x| x == id.get())
|
||||||
{
|
{
|
||||||
// If removed container is currently selected, then change selected to previous
|
// If removed container is currently selected, then change selected to previous
|
||||||
// This will default to 0 in any edge cases
|
// This will default to 0 in any edge cases
|
||||||
@@ -446,8 +446,8 @@ impl AppData {
|
|||||||
|
|
||||||
for i in all_containers.iter_mut() {
|
for i in all_containers.iter_mut() {
|
||||||
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(), |n| {
|
let name = i.names.as_mut().map_or("".to_owned(), |names| {
|
||||||
n.get_mut(0).map_or("".to_owned(), |f| {
|
names.first_mut().map_or("".to_owned(), |f| {
|
||||||
if f.starts_with('/') {
|
if f.starts_with('/') {
|
||||||
f.remove(0);
|
f.remove(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user