summaryrefslogtreecommitdiff
path: root/src/devices/file/directory_child.rs
blob: 376ec7dd3cb579b017345f9b182e98ff3ec16d76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use super::*;

use std::cmp::Ordering;


pub struct DirectoryChild {
    pub path: BedrockFilePath,
    pub entry_type: EntryType,
}


// ---------------------------------------------------------------------------

impl PartialEq for DirectoryChild {
    fn eq(&self, other: &Self) -> bool {
        self.entry_type == other.entry_type && self.path == other.path
    }
}

impl Eq for DirectoryChild {}

impl PartialOrd for DirectoryChild {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for DirectoryChild {
    fn cmp(&self, other: &Self) -> Ordering {
        match self.entry_type.cmp(&other.entry_type) {
            Ordering::Equal => self.path.cmp(&other.path),
            ordering => ordering,
        }
    }
}