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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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::OptimizationLevel {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			Self::O0 => write!(f, "0"),
			Self::O1 => write!(f, "1"),
			Self::O2 => write!(f, "2"),
			Self::O3 => write!(f, "3"),
			Self::Os => write!(f, "s"),
			Self::Oz => write!(f, "z"),
		}
	}
}

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::TargetInfo {
	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
		write!(f, "{}", self.triple)
	}
}

impl std::fmt::Display for crate::CpuInfo {
	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
		write!(f, "{}", self.arch)
	}
}

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(())
	}
}