build_script_cfg/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(warnings, missing_docs)]
3
4/// The type that represents a configuration option.
5#[derive(Clone, PartialEq, Eq, Debug)]
6#[repr(transparent)]
7pub struct Cfg<S>(S);
8
9impl<S: std::fmt::Display> Cfg<S> {
10    /// Creates a new configuration option with the given name.
11    #[inline]
12    pub fn new(name: S) -> Self {
13        println!("cargo::rustc-check-cfg=cfg({name})");
14        Self(name)
15    }
16
17    /// Sets the corresponding `rustc-cfg` flag.
18    #[inline]
19    pub fn define(self) {
20        println!("cargo:rustc-cfg={}", self.0)
21    }
22}