https://github.com/flier/rust-runtime-cfg
Evaluation of configuration flags, at runtime-time.
https://github.com/flier/rust-runtime-cfg
Last synced: over 1 year ago
JSON representation
Evaluation of configuration flags, at runtime-time.
- Host: GitHub
- URL: https://github.com/flier/rust-runtime-cfg
- Owner: flier
- License: apache-2.0
- Created: 2019-05-29T11:09:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-31T08:04:44.000Z (about 7 years ago)
- Last Synced: 2025-01-21T22:09:41.455Z (over 1 year ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# runtime_cfg [](https://travis-ci.org/flier/rust-runtime-cfg) [](https://crates.io/crates/runtime_cfg) [](https://docs.rs/crate/runtime_cfg/) [](https://deps.rs/repo/github/flier/rust-runtime-cfg)
Evaluation of configuration flags, at runtime-time.
## Usage
To use `runtime_cfg` in your project, add the following to your Cargo.toml:
``` toml
[dependencies]
runtime-cfg = "0.1"
```
## Example
```rust
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));
```