mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 17:35:16 +01:00
make DirEntry Ord
This commit is contained in:
parent
47e30d3d4a
commit
60c14b1af2
2 changed files with 24 additions and 1 deletions
|
@ -16,6 +16,7 @@ pub struct DirEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirEntry {
|
impl DirEntry {
|
||||||
|
#[inline]
|
||||||
pub fn normal(e: ignore::DirEntry) -> Self {
|
pub fn normal(e: ignore::DirEntry) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: DirEntryInner::Normal(e),
|
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<std::cmp::Ordering> {
|
||||||
|
self.path().partial_cmp(other.path())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for DirEntry {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.path().cmp(other.path())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ impl<W: Write> ReceiverBuffer<W> {
|
||||||
/// Stop looping.
|
/// Stop looping.
|
||||||
fn stop(&mut self) -> Result<(), ExitCode> {
|
fn stop(&mut self) -> Result<(), ExitCode> {
|
||||||
if self.mode == ReceiverMode::Buffering {
|
if self.mode == ReceiverMode::Buffering {
|
||||||
self.buffer.sort_by(|e1, e2| e1.path().cmp(e2.path()));
|
self.buffer.sort();
|
||||||
self.stream()?;
|
self.stream()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue