diff --git a/src/app_data/mod.rs b/src/app_data/mod.rs index f355f2b..3df0b3c 100644 --- a/src/app_data/mod.rs +++ b/src/app_data/mod.rs @@ -278,12 +278,12 @@ impl AppData { fn set_sorted(&mut self, x: Option<(Header, SortedOrder)>) { self.sorted_by = x; self.sort_containers(); - self.containers - .state - .select(self.containers.items.iter().position(|i| { - self.get_selected_container_id() - .map_or(false, |id| i.id == id) - })); + self.containers.state.select( + self.containers + .items + .iter() + .position(|i| self.get_selected_container_id().as_ref() == Some(&i.id)), + ); } /// Remove the sorted header & order, and sort by default - created datetime @@ -676,13 +676,13 @@ impl AppData { /// So that can disallow commands to be send /// Is a shabby way of implementing this pub fn is_oxker(&self) -> bool { - self.get_selected_container().map_or(false, |i| i.is_oxker) + self.get_selected_container().is_some_and(|i| i.is_oxker) } /// Check if selected container is oxker and also that oxker is being run in a container pub fn is_oxker_in_container(&self) -> bool { self.get_selected_container() - .map_or(false, |i| i.is_oxker && self.args.in_container) + .is_some_and(|i| i.is_oxker && self.args.in_container) } /// Find the widths for the strings in the containers panel. @@ -817,7 +817,7 @@ impl AppData { let is_oxker = i .command .as_ref() - .map_or(false, |i| i.starts_with(ENTRY_POINT)); + .is_some_and(|i| i.starts_with(ENTRY_POINT)); let status = ContainerStatus::from( i.status diff --git a/src/docker_data/mod.rs b/src/docker_data/mod.rs index b288af3..173b6e6 100644 --- a/src/docker_data/mod.rs +++ b/src/docker_data/mod.rs @@ -217,7 +217,7 @@ impl DockerData { if self.args.in_container && f.command .as_ref() - .map_or(false, |c| c.starts_with(ENTRY_POINT)) + .is_some_and(|c| c.starts_with(ENTRY_POINT)) && self.args.show_self { None diff --git a/src/parse_args.rs b/src/parse_args.rs index 911ba20..a8067a9 100644 --- a/src/parse_args.rs +++ b/src/parse_args.rs @@ -70,7 +70,7 @@ impl CliArgs { /// An ENV is set in the ./containerised/Dockerfile, if this is ENV found, then sleep for 250ms, else the container, for as yet unknown reasons, will close immediately /// returns a bool, so that the `update_all_containers()` won't bother to check the entry point unless running via a container fn check_if_in_container() -> bool { - std::env::var(ENV_KEY).map_or(false, |i| i == ENV_VALUE) + std::env::var(ENV_KEY).is_ok_and(|i| i == ENV_VALUE) } /// Parse cli arguments