some fiddling with the display

This commit is contained in:
Chris West (Faux) 2017-07-13 22:01:45 +01:00
parent 457c31b4a4
commit d935fa5fb7
3 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,9 @@ license = "MIT"
lazy_static = "0.2.8" lazy_static = "0.2.8"
libc = "0.2.26" libc = "0.2.26"
[dev-dependencies]
itertools = "0.6.0"
[build-dependencies] [build-dependencies]
gcc = "0.3.51" gcc = "0.3.51"

View File

@ -1,4 +1,7 @@
extern crate apt_pkg_native; extern crate apt_pkg_native;
extern crate itertools;
use itertools::Itertools;
use apt_pkg_native::Cache; use apt_pkg_native::Cache;
use apt_pkg_native::simple; use apt_pkg_native::simple;
@ -6,6 +9,6 @@ use apt_pkg_native::simple;
fn main() { fn main() {
let mut cache = Cache::get_singleton(); let mut cache = Cache::get_singleton();
for item in cache.iter().map(simple::BinaryPackageVersions::new) { 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(", "));
} }
} }

View File

@ -62,10 +62,11 @@ impl Version {
impl fmt::Display for Version { impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{} in {:?} from {}:{} at {}", write!(f, "{}:{}", self.version, self.arch)?;
self.version, if let Some(ref section) = self.section {
self.arch, write!(f, " in {}", section)?;
self.section, }
write!(f, " from {}:{} at {}",
self.source_package, self.source_package,
self.source_version, self.source_version,
self.priority, self.priority,