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
.
This does not automatically call emit_possibility
so the compiler my generate an unexpected_cfgs
warning.
However, all the builtin emit methods on AutoCfg
call emit_possibility
automatically.
Examples found in repository?
examples/nightly.rs (line 16)
3fn main() {
4 // Normally, cargo will set `OUT_DIR` for build scripts.
5 let ac = autocfg::AutoCfg::with_dir("target").unwrap();
6
7 // When this feature was stabilized, it also renamed the method to
8 // `chunk_by`, so it's important to *use* the feature in your probe.
9 let code = r#"
10 #![feature(slice_group_by)]
11 pub fn probe(slice: &[i32]) -> impl Iterator<Item = &[i32]> {
12 slice.group_by(|a, b| a == b)
13 }
14 "#;
15 if ac.probe_raw(code).is_ok() {
16 autocfg::emit("has_slice_group_by");
17 }
18}