diff --git a/src/dir_entry.rs b/src/dir_entry.rs index 6eae14a..5def5de 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -16,6 +16,7 @@ pub struct DirEntry { } impl DirEntry { + #[inline] pub fn normal(e: ignore::DirEntry) -> Self { Self { inner: DirEntryInner::Normal(e), @@ -67,3 +68,25 @@ impl DirEntry { } } } + +impl PartialEq for DirEntry { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.path() == other.path() + } +} +impl Eq for DirEntry {} + +impl PartialOrd for DirEntry { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + self.path().partial_cmp(other.path()) + } +} + +impl Ord for DirEntry { + #[inline] + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.path().cmp(other.path()) + } +} diff --git a/src/walk.rs b/src/walk.rs index 7c22227..463417e 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -310,7 +310,7 @@ impl ReceiverBuffer { /// Stop looping. fn stop(&mut self) -> Result<(), ExitCode> { if self.mode == ReceiverMode::Buffering { - self.buffer.sort_by(|e1, e2| e1.path().cmp(e2.path())); + self.buffer.sort(); self.stream()?; }