-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
AutoCfg::probe_raw
for free-form probes
This takes an arbitrary string that will be fed to the compiler as-is, without even interjecting `#![no_std]` like other probe methods. It also returns a `Result` with the full `Error`, so you could choose to print verbose details on failure, for example.
- Loading branch information
Showing
4 changed files
with
118 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extern crate autocfg; | ||
|
||
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters