diff --git a/src/check.rs b/src/check.rs index 425ebfd..32e8a65 100644 --- a/src/check.rs +++ b/src/check.rs @@ -24,13 +24,12 @@ pub async fn get_updates(references: &Option>, config: &Config) -> V .iter() .filter(|&reference| !image_refs.contains(reference)) .collect::>(); - let mut handles = Vec::with_capacity(extra.len()); - - for reference in extra { - let future = Image::from_reference(reference); - handles.push(future) - } - Some(join_all(handles).await) + Some( + extra + .iter() + .map(|reference| Image::from_reference(reference)) + .collect::>(), + ) } None => None, }; diff --git a/src/docker.rs b/src/docker.rs index b18bc34..cd8b319 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -41,14 +41,9 @@ pub async fn get_images_from_docker_daemon( .filter(|inspect| inspect.is_ok()) .map(|inspect| inspect.as_ref().unwrap().clone()) .collect(); - let mut image_handles = Vec::with_capacity(inspects.len()); - for inspect in inspects { - image_handles.push(Image::from_inspect_data(inspect)); - } - join_all(image_handles) - .await + inspects .iter() - .filter_map(|img| img.clone()) + .filter_map(|inspect| Image::from_inspect_data(inspect.clone())) .collect() } None => { @@ -58,14 +53,9 @@ pub async fn get_images_from_docker_daemon( error!("Failed to retrieve list of images available!\n{}", e) } }; - let mut handles = Vec::new(); - for image in images { - handles.push(Image::from_inspect_data(image)) - } - join_all(handles) - .await + images .iter() - .filter_map(|img| img.clone()) + .filter_map(|image| Image::from_inspect_data(image.clone())) .collect() } } diff --git a/src/structs/image.rs b/src/structs/image.rs index c451d9d..e1b0a1b 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -42,7 +42,7 @@ pub struct Image { impl Image { /// Creates and populates the fields of an Image object based on the ImageSummary from the Docker daemon - pub async fn from_inspect_data(image: T) -> Option { + pub fn from_inspect_data(image: T) -> Option { let tags = image.tags().unwrap(); let digests = image.digests().unwrap(); if !tags.is_empty() && !digests.is_empty() { @@ -74,7 +74,7 @@ impl Image { } /// Creates and populates the fields of an Image object based on a reference. If the tag is not recognized as a version string, exits the program with an error. - pub async fn from_reference(reference: &str) -> Self { + pub fn from_reference(reference: &str) -> Self { let (registry, repository, tag) = split(reference); let version_tag = Version::from_tag(&tag); match version_tag {