mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-27 01:20:48 +00:00
Use question mark on Option
This commit is contained in:
parent
f081412819
commit
25ae9526bc
16
build.rs
16
build.rs
@ -88,20 +88,10 @@ struct RustcVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rustc_version() -> Option<RustcVersion> {
|
fn rustc_version() -> Option<RustcVersion> {
|
||||||
macro_rules! otry {
|
let rustc = env::var_os("RUSTC")?;
|
||||||
($e:expr) => {
|
let output = Command::new(rustc).arg("--version").output().ok()?;
|
||||||
match $e {
|
let version = str::from_utf8(&output.stdout).ok()?;
|
||||||
Some(e) => e,
|
|
||||||
None => return None,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let rustc = otry!(env::var_os("RUSTC"));
|
|
||||||
let output = otry!(Command::new(rustc).arg("--version").output().ok());
|
|
||||||
let version = otry!(str::from_utf8(&output.stdout).ok());
|
|
||||||
let nightly = version.contains("nightly");
|
let nightly = version.contains("nightly");
|
||||||
|
|
||||||
Some(RustcVersion { nightly })
|
Some(RustcVersion { nightly })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user