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
36
|
use super::*;
use std::cmp::Ordering;
pub enum Entry {
File(BufferedFile),
Directory(DirectoryListing),
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum EntryType {
File,
Directory,
}
impl PartialOrd for EntryType {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(EntryType::Directory, EntryType::Directory) => Some(Ordering::Equal ),
(EntryType::Directory, EntryType::File ) => Some(Ordering::Less ),
(EntryType::File, EntryType::Directory) => Some(Ordering::Greater),
(EntryType::File, EntryType::File ) => Some(Ordering::Equal ),
}
}
}
impl Ord for EntryType {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(EntryType::Directory, EntryType::Directory) => Ordering::Equal ,
(EntryType::Directory, EntryType::File ) => Ordering::Less ,
(EntryType::File, EntryType::Directory) => Ordering::Greater,
(EntryType::File, EntryType::File ) => Ordering::Equal ,
}
}
}
|