diff --git a/Cargo.toml b/Cargo.toml index b43e332..a153cb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ pkg-config = "0.3" toml = { version = "0.5", default-features = false } version-compare = "0.0.11" heck = "0.3" -itertools = "0.10" cfg-expr = "0.8" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 69edfaa..2186ecf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -173,7 +173,6 @@ extern crate lazy_static; mod test; use heck::{ShoutySnakeCase, SnakeCase}; -use itertools::Itertools; use std::collections::HashMap; use std::env; use std::fmt; @@ -276,65 +275,68 @@ impl Dependencies { self.libs.iter().map(|(k, v)| (k.as_str(), v)) } - fn aggregate_str &Vec>( - &self, - getter: F, - ) -> impl Iterator { - self.libs + fn aggregate_str &Vec>(&self, getter: F) -> Vec<&str> { + let mut v = self + .libs .values() .map(|l| getter(l)) .flatten() .map(|s| s.as_str()) - .sorted() - .dedup() + .collect::>(); + v.sort(); + v.dedup(); + v } - fn aggregate_path_buf &Vec>( - &self, - getter: F, - ) -> impl Iterator { - self.libs + fn aggregate_path_buf &Vec>(&self, getter: F) -> Vec<&PathBuf> { + let mut v = self + .libs .values() .map(|l| getter(l)) .flatten() - .sorted() - .dedup() + .collect::>(); + v.sort(); + v.dedup(); + v } /// An iterator returning each [Library::libs] of each library, removing duplicates. - pub fn all_libs(&self) -> impl Iterator { + pub fn all_libs(&self) -> Vec<&str> { self.aggregate_str(|l| &l.libs) } /// An iterator returning each [Library::link_paths] of each library, removing duplicates. - pub fn all_link_paths(&self) -> impl Iterator { + pub fn all_link_paths(&self) -> Vec<&PathBuf> { self.aggregate_path_buf(|l| &l.link_paths) } /// An iterator returning each [Library::frameworks] of each library, removing duplicates. - pub fn all_frameworks(&self) -> impl Iterator { + pub fn all_frameworks(&self) -> Vec<&str> { self.aggregate_str(|l| &l.frameworks) } /// An iterator returning each [Library::framework_paths] of each library, removing duplicates. - pub fn all_framework_paths(&self) -> impl Iterator { + pub fn all_framework_paths(&self) -> Vec<&PathBuf> { self.aggregate_path_buf(|l| &l.framework_paths) } /// An iterator returning each [Library::include_paths] of each library, removing duplicates. - pub fn all_include_paths(&self) -> impl Iterator { + pub fn all_include_paths(&self) -> Vec<&PathBuf> { self.aggregate_path_buf(|l| &l.include_paths) } /// An iterator returning each [Library::defines] of each library, removing duplicates. - pub fn all_defines(&self) -> impl Iterator)> { - self.libs + pub fn all_defines(&self) -> Vec<(&str, &Option)> { + let mut v = self + .libs .values() .map(|l| l.defines.iter()) .flatten() .map(|(k, v)| (k.as_str(), v)) - .sorted() - .dedup() + .collect::>(); + v.sort(); + v.dedup(); + v } fn add(&mut self, name: &str, lib: Library) { diff --git a/src/test.rs b/src/test.rs index c901766..553732c 100644 --- a/src/test.rs +++ b/src/test.rs @@ -815,31 +815,28 @@ fn optional() { fn aggregate() { let (libraries, _) = toml("toml-two-libs", vec![]).unwrap(); + assert_eq!(libraries.all_libs(), vec!["test", "test2"]); assert_eq!( - libraries.all_libs().collect::>(), - vec!["test", "test2"] - ); - assert_eq!( - libraries.all_link_paths().collect::>(), + libraries.all_link_paths(), vec![Path::new("/usr/lib"), Path::new("/usr/lib64")] ); assert_eq!( - libraries.all_frameworks().collect::>(), + libraries.all_frameworks(), vec!["someframework", "someotherframework"] ); assert_eq!( - libraries.all_framework_paths().collect::>(), + libraries.all_framework_paths(), vec![Path::new("/usr/lib"), Path::new("/usr/lib64")] ); assert_eq!( - libraries.all_include_paths().collect::>(), + libraries.all_include_paths(), vec![ Path::new("/usr/include/testanotherlib"), Path::new("/usr/include/testlib") ] ); assert_eq!( - libraries.all_defines().collect::>(), + libraries.all_defines(), vec![ ("AWESOME", &None), ("BADGER", &Some("yes".into())),