Macro try_compile

Source
macro_rules! try_compile {
    ($config:expr, { $($tokens:tt)* }$(,)?) => { ... };
    ({ $($tokens:tt)* }$(,)?) => { ... };
}
Expand description

Compiles the given string of tokens and returns the output.

This macro will return an error if we fail to invoke the compiler. Unlike the compile! macro, this will not panic.

let output = postcompile::try_compile!({
    const TEST: u32 = 1;
});

assert!(output.is_ok());
assert_eq!(output.unwrap().status, postcompile::ExitStatus::Success);