Skip to content

Commit

Permalink
Do not rely on debug print format
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Nov 2, 2020
1 parent ddc3925 commit 3a73a9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
fn main() {
let rustc = env::var_os("RUSTC").map_or_else(|| "rustc".into(), PathBuf::from);
let version = match Version::from_rustc(&rustc) {
Ok(version) => format!("{:#?}\n", version),
Ok(version) => version.print(),
Err(e) => panic!("{}", e),
};

Expand All @@ -26,7 +26,6 @@ fn main() {
println!("cargo:rustc-cfg=const_fn_has_build_script");
}

#[derive(Debug)]
struct Version {
minor: u32,
nightly: bool,
Expand Down Expand Up @@ -88,4 +87,8 @@ impl Version {
let nightly = channel.map_or(false, |c| c == "dev" || c == "nightly");
Ok(Self { minor, nightly })
}

fn print(&self) -> String {
format!("Version {{ minor: {}, nightly: {} }}", self.minor, self.nightly)
}
}

0 comments on commit 3a73a9f

Please sign in to comment.