no-std runtime_cfg

Evaluation of configuration flags, at runtime-time

1 unstable release

0.1.0 May 29, 2019

MIT/Apache

22KB
550 lines

runtime_cfg travis crate docs

Evaluation of configuration flags, at runtime-time.

Usage

To use runtime_cfg in your project, add the following to your Cargo.toml:

[dependencies]
runtime-cfg = "0.1"

Example

use std::convert::TryFrom;

use quote::quote;

use runtime_cfg::*;

let cfg = quote! { #[cfg(all(unix, target_pointer_width = "32"))] };

let cfg = Cfg::try_from(cfg).unwrap();
assert_eq!(cfg, all(vec![name("unix"), name_value("target_pointer_width", "32")]).into());

let flags = vec![("unix", None), ("target_pointer_width", Some("32"))];
assert!(cfg.matches(&flags));


lib.rs:

Evaluation of configuration flags, at runtime-time.

Example

use std::convert::TryFrom;

use quote::quote;

use runtime_cfg::*;

let cfg = quote! { #[cfg(all(unix, target_pointer_width = "32"))] };

let cfg = Cfg::try_from(cfg).unwrap();
assert_eq!(cfg, all(vec![name("unix"), name_value("target_pointer_width", "32")]).into());

let flags = vec![("unix", None), ("target_pointer_width", Some("32"))];
assert!(cfg.matches(&flags));

Dependencies

~8–470KB
~11K SLoC