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
37
38
39
40
use super::*;
use crate::TypeReader;

#[derive(Copy, Clone)]
pub struct ModuleRef {
    pub reader: &'static TypeReader,
    pub row: Row,
}

impl ModuleRef {
    pub fn name(&self) -> &'static str {
        self.reader.str(self.row, 0)
    }
}

impl std::fmt::Debug for ModuleRef {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("ModuleRef").field("row", &self.row).finish()
    }
}

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

impl Eq for ModuleRef {}

impl Ord for ModuleRef {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.row.cmp(&other.row)
    }
}

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