build_info_common/
display.rs1impl std::fmt::Display for crate::BuildInfo {
2 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3 write!(f, "{} {} build", self.crate_info, self.profile)?;
4
5 if let Some(crate::VersionControl::Git(ref git)) = self.version_control {
6 write!(f, " from {git}")?;
7 }
8
9 Ok(())
10 }
11}
12
13impl std::fmt::Display for crate::OptimizationLevel {
14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 match self {
16 Self::O0 => write!(f, "0"),
17 Self::O1 => write!(f, "1"),
18 Self::O2 => write!(f, "2"),
19 Self::O3 => write!(f, "3"),
20 Self::Os => write!(f, "s"),
21 Self::Oz => write!(f, "z"),
22 }
23 }
24}
25
26impl std::fmt::Display for crate::CrateInfo {
27 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28 write!(f, "{} v{}", self.name, self.version)
29 }
30}
31
32impl std::fmt::Display for crate::TargetInfo {
33 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34 write!(f, "{}", self.triple)
35 }
36}
37
38impl std::fmt::Display for crate::CpuInfo {
39 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
40 write!(f, "{}", self.arch)
41 }
42}
43
44impl std::fmt::Display for crate::CompilerInfo {
45 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46 write!(f, "rustc {}", self.version)?;
47
48 if let Some(ref commit_id) = self.commit_id {
49 let commit_id = &commit_id[0..9];
50 if let Some(ref commit_date) = self.commit_date {
51 write!(f, " ({commit_id} {commit_date})")?;
52 } else {
53 write!(f, " ({commit_id})")?;
54 }
55 }
56
57 Ok(())
58 }
59}
60
61impl std::fmt::Display for crate::VersionControl {
62 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
63 match self {
64 crate::VersionControl::Git(git) => write!(f, "{git}"),
65 }
66 }
67}
68
69impl std::fmt::Display for crate::GitInfo {
70 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
71 write!(f, "{}", &self.commit_id)?;
72
73 if self.dirty {
74 write!(f, ".+")?;
75 }
76
77 if let Some(branch) = &self.branch {
78 write!(f, " ({branch})")?;
79 }
80
81 Ok(())
82 }
83}