[go: up one dir, main page]

Function autocfg::emit

source ·
pub fn emit(cfg: &str)
Expand description

Writes a config flag for rustc on standard out.

This looks like: cargo:rustc-cfg=CFG

Cargo will use this in arguments to rustc, like --cfg CFG.

Examples found in repository?
examples/nightly.rs (line 16)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
fn main() {
    // Normally, cargo will set `OUT_DIR` for build scripts.
    let ac = autocfg::AutoCfg::with_dir("target").unwrap();

    // When this feature was stabilized, it also renamed the method to
    // `chunk_by`, so it's important to *use* the feature in your probe.
    let code = r#"
        #![feature(slice_group_by)]
        pub fn probe(slice: &[i32]) -> impl Iterator<Item = &[i32]> {
            slice.group_by(|a, b| a == b)
        }
    "#;
    if ac.probe_raw(code).is_ok() {
        autocfg::emit("has_slice_group_by");
    }
}