/// Test if a code snippet can be compiled
Test if a code snippet can be compiled
Test if a code snippet can be compiled
fn probe(code: &str) -> bool {
    let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
    let out_dir = env::var_os("OUT_DIR").expect("environment variable OUT_DIR");
    let mut child = Command::new(rustc)
        .arg("--out-dir")
        .arg(out_dir)
        .arg("--emit=obj")
        .arg("-")
        .stdin(Stdio::piped())
        .spawn()
        .expect("rustc probe");
    child
        .stdin
        .as_mut()
        .expect("rustc stdin")
        .write_all(code.as_bytes())
        .expect("write rustc stdin");
    child.wait().expect("rustc probe").success()
}
fn probe ( code : & str ) -> bool { let rustc = env :: var_os ( " " ) . unwrap_or_else ( | | " " . into ( ) ) ; let out_dir = env :: var_os ( " " ) . expect ( " " ) ; let mut child = Command :: new ( rustc ) . arg ( " " ) . arg ( out_dir ) . arg ( " " ) . arg ( " " ) . stdin ( Stdio :: piped ( ) ) . spawn ( ) . expect ( " " ) ; child . stdin . as_mut ( ) . expect ( " " ) . write_all ( code . as_bytes ( ) ) . expect ( " " ) ; child . wait ( ) . expect ( " " ) . success ( ) }
Test if a code snippet can be compiled
Test if a code snippet can be compiled
code
&str