cuviper / autocfg

Automatic cfg for Rust compiler features
Apache License 2.0
95 stars 24 forks source link

Test for specific named feature in std? #54

Closed schneems closed 10 months ago

schneems commented 10 months ago

Hello, thanks for the great library. I am wondering if it's possible to test for something like this feature https://doc.rust-lang.org/src/std/path.rs.html#2889

    #[stable(feature = "path_try_exists", since = "1.63.0")]

I can use the 1.63 version test, but I didn't know if there was a way to be a bit more specific for why I'm wanting that version.

cuviper commented 10 months ago

I'm not aware of any way that the feature names can be inspected. Apart from writing yourself a comment about the significance of 1.63, the only other thing in autocfg is to test something like:

let ac = autocfg::new();
ac.emit_expression_cfg("Path::new(\"\").try_exists()", "has_path_try_exists");

... or a similar probe_expression followed by whatever action you choose.

schneems commented 10 months ago

Thanks that answers my question. Appreciate the great library!