pub enum Cfg<String = String> {
Any(Vec<Cfg<String>>),
All(Vec<Cfg<String>>),
Not(Box<Cfg<String>>),
Equal(String, String),
Is(String),
}
Variants§
Implementations§
source§impl<String: AsRef<str>> Cfg<String>
impl<String: AsRef<str>> Cfg<String>
sourcepub fn eval<'cfg, GetterCallback>(&'cfg self, getter: GetterCallback) -> boolwhere
GetterCallback: Fn(&'cfg str, &'cfg str) -> Option<&'cfg str>,
pub fn eval<'cfg, GetterCallback>(&'cfg self, getter: GetterCallback) -> boolwhere GetterCallback: Fn(&'cfg str, &'cfg str) -> Option<&'cfg str>,
Check if the cfg matches keys returned by the getter.
The getter takes a key, and a hint of the value that it’s being compared against (to handle feature = "value"
).
Value given to the callback will be ""
for existence checks (like cfg(unix)
).
The callback returns Some
with the key’s actual value if it’s set, or None
if the key is not set. For booleans equal true return Some("")
.
NB: don’t use move
closures for the callback, because these aren’t allowed to return data they own. Use closures temporarily borrowing the data from their outer scope.
See rustc --print=cfg
for list of values to set to emulate proper environment.
source§impl<'input> Cfg<&'input str>
impl<'input> Cfg<&'input str>
sourcepub fn parse_ref(cfg_str: &'input str) -> Result<Self, ParseError>
pub fn parse_ref(cfg_str: &'input str) -> Result<Self, ParseError>
Parse cfg(…)
expression into temporary &str
s
source§impl Cfg<String>
impl Cfg<String>
sourcepub fn parse(cfg_str: &str) -> Result<Self, ParseError>
pub fn parse(cfg_str: &str) -> Result<Self, ParseError>
Parse cfg(…)
expression into owning String
s.
source§impl<'input, String: From<&'input str>> Cfg<String>
impl<'input, String: From<&'input str>> Cfg<String>
sourcepub fn parse_generic(cfg_str: &'input str) -> Result<Self, ParseError>
pub fn parse_generic(cfg_str: &'input str) -> Result<Self, ParseError>
Parse cfg(…)
expression into any string-like type
sourcepub fn parse_inner_expr(cfg_inner_str: &'input str) -> Result<Self, ParseError>
pub fn parse_inner_expr(cfg_inner_str: &'input str) -> Result<Self, ParseError>
Parse the inner X
of expression cfg(X)
Use Cfg::<String>::parse_inner_expr(input)
.