From f6c5c89f55c694f04f9f0a1269f5c4945450d78b Mon Sep 17 00:00:00 2001 From: Ben S Date: Thu, 31 Mar 2016 23:13:15 +0100 Subject: Always sort files the same way This fixes a bug where extra sorting options (dirs first, reverse) were not applied when listing in long mode. In other words, fixes #105. The bug occurred because the sorting function only took Files, but the details view uses File eggs that only contain Files. This commit changes the sorting function to accept anything that AsRefs to File, and impls that on both File and Egg so the same function works for both. --- src/output/details.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/output') diff --git a/src/output/details.rs b/src/output/details.rs index ed75abf..c663d91 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -229,12 +229,18 @@ impl Details { let mut pool = Pool::new(num_cpus::get() as u32); let mut file_eggs = Vec::new(); - struct Egg<'_> { + struct Egg<'a> { cells: Vec, xattrs: Vec, errors: Vec<(io::Error, Option)>, dir: Option, - file: File<'_>, + file: File<'a>, + } + + impl<'a> AsRef> for Egg<'a> { + fn as_ref(&self) -> &File<'a> { + &self.file + } } pool.scoped(|scoped| { @@ -285,7 +291,7 @@ impl Details { } }); - file_eggs.sort_by(|a, b| self.filter.compare_files(&a.file, &b.file)); + self.filter.sort_files(&mut file_eggs); let num_eggs = file_eggs.len(); for (index, egg) in file_eggs.into_iter().enumerate() { -- cgit v1.2.3