source_cache/identifier/
display.rs1use super::*;
2
3impl Display for SourcePath {
4 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5 match self {
6 Self::Anonymous => f.write_str("<anonymous>"),
7 Self::Snippet(s) => f.write_str(s),
8 Self::Local(s) => match Url::from_file_path(s) {
9 Ok(s) => f.write_str(s.as_str()),
10 Err(_) => f.write_str(&s.to_string_lossy()),
11 },
12 Self::Remote(s) => f.write_str(s.as_str()),
13 }
14 }
15}
16
17impl Debug for SourceID {
18 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
19 write!(f, "FileID(0x{:X})", self.hash)
20 }
21}
22
23impl Display for SourceID {
24 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
25 Debug::fmt(self, f)
26 }
27}