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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
impl std::fmt::Display for crate::BuildInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{} {} build", self.crate_info, self.profile)?;
if let Some(crate::VersionControl::Git(ref git)) = self.version_control {
write!(f, " from {}", git)?;
}
Ok(())
}
}
impl std::fmt::Display for crate::CrateInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{} v{}", self.name, self.version)
}
}
impl std::fmt::Display for crate::CompilerInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "rustc {}", self.version)?;
if let Some(ref commit_id) = self.commit_id {
let commit_id = &commit_id[0..9];
if let Some(ref commit_date) = self.commit_date {
write!(f, " ({} {})", commit_id, commit_date)?;
} else {
write!(f, " ({})", commit_id)?;
}
}
Ok(())
}
}
impl std::fmt::Display for crate::VersionControl {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
crate::VersionControl::Git(ref git) => write!(f, "{}", git),
}
}
}
impl std::fmt::Display for crate::GitInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", &self.commit_id)?;
if self.dirty {
write!(f, ".+")?;
}
if let Some(branch) = &self.branch {
write!(f, " ({})", branch)?;
}
Ok(())
}
}