aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--build.rs13
2 files changed, 9 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a7af9fb..6480c5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
# Unreleased
- Derive `Debug` for all structs generated by `bindgen`.
+- Implement `std::fmt::Display` instead of `std::string::ToString` for the
+ `Version` enum in `build.rs`.
# v3.5.0 (2019-07-04)
- Mark deprecated functions using the `deprecated` attribute.
diff --git a/build.rs b/build.rs
index a9d0778..24fdf0a 100644
--- a/build.rs
+++ b/build.rs
@@ -1,9 +1,9 @@
use std::env;
+use std::fmt;
use std::fs;
use std::io;
use std::io::{Read, Write};
use std::path;
-use std::string;
use cc;
@@ -14,12 +14,13 @@ struct Version {
patch: Option<u32>,
}
-impl string::ToString for Version {
- fn to_string(&self) -> String {
- match self.patch {
- Some(patch) => format!("v{}.{}.{}", self.major, self.minor, patch),
- None => format!("v{}.{}", self.major, self.minor),
+impl fmt::Display for Version {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "v{}.{}", self.major, self.minor)?;
+ if let Some(patch) = self.patch {
+ write!(f, ".{}", patch)?;
}
+ Ok(())
}
}