diff --git a/Cargo.toml b/Cargo.toml index 40e4128..652988d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,9 @@ license = "MIT" lazy_static = "0.2.8" libc = "0.2.26" +[dev-dependencies] +itertools = "0.6.0" + [build-dependencies] gcc = "0.3.51" diff --git a/examples/list.rs b/examples/list.rs index ab3f246..e869a0c 100644 --- a/examples/list.rs +++ b/examples/list.rs @@ -1,4 +1,7 @@ extern crate apt_pkg_native; +extern crate itertools; + +use itertools::Itertools; use apt_pkg_native::Cache; use apt_pkg_native::simple; @@ -6,6 +9,6 @@ use apt_pkg_native::simple; fn main() { let mut cache = Cache::get_singleton(); for item in cache.iter().map(simple::BinaryPackageVersions::new) { - println!("{}: {:?}", item.pkg, item.versions); + println!("{} [{}]", item.pkg, item.versions.iter().map(|x| format!("{}", x)).join(", ")); } } diff --git a/src/simple.rs b/src/simple.rs index 23335fb..5b2f6cc 100644 --- a/src/simple.rs +++ b/src/simple.rs @@ -62,10 +62,11 @@ impl Version { impl fmt::Display for Version { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}:{} in {:?} from {}:{} at {}", - self.version, - self.arch, - self.section, + write!(f, "{}:{}", self.version, self.arch)?; + if let Some(ref section) = self.section { + write!(f, " in {}", section)?; + } + write!(f, " from {}:{} at {}", self.source_package, self.source_version, self.priority,