Skip to content

Instantly share code, notes, and snippets.

@luser
Created March 1, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luser/859206ae83767bbea821e832993e8b1c to your computer and use it in GitHub Desktop.
Save luser/859206ae83767bbea821e832993e8b1c to your computer and use it in GitHub Desktop.
some rust with a compile error
let is_rustc = if filename.to_string_lossy().to_lowercase() == "rustc" {
// Sanity check that it's really rustc.
let child = creator.clone().new_command_sync(&executable)
.stdout(Stdio::piped())
.stderr(Stdio::null())
.args(&["--version"])
.spawn().chain_err(|| {
format!("failed to execute {:?}", executable)
});
let output = child.into_future().and_then(move |child| {
child.wait_with_output()
.chain_err(|| "failed to read child output")
});
Box::new(output.map(|output| {
if output.status.success() {
if let Ok(stdout) = String::from_utf8(output.stdout) {
if stdout.starts_with("rustc ") {
return true;
}
}
}
false
}))
} else {
future::ok(false).boxed()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment