[−][src]Struct cfg_expr::expr::Expression
A parsed cfg()
expression that can evaluated
Methods
impl Expression
[src]
pub fn parse(original: &str) -> Result<Self, ParseError>
[src]
Given a cfg() expression (the cfg( and ) are optional), attempts to parse it into a form where it can be evaluated
assert!(cfg_expr::Expression::parse(r#"cfg(all(unix, target_arch = "x86_64"))"#).is_ok());
impl Expression
[src]
pub fn predicates(&self) -> impl Iterator<Item = Predicate>
[src]
An iterator over each predicate in the expression
pub fn eval<EP: FnMut(&Predicate) -> bool>(&self, eval_predicate: EP) -> bool
[src]
Evaluates the expression, using the provided closure to determine the value of each predicate, which are then combined into a final result depending on the functions not(), all(), or any() in the expression
use cfg_expr::{targets::*, Expression, Predicate}; let linux_musl = get_target_by_triple("x86_64-unknown-linux-musl").unwrap(); let expr = Expression::parse(r#"all(not(windows), target_env = "musl", any(target_arch = "x86", target_arch = "x86_64"))"#).unwrap(); assert!(expr.eval(|pred| { match pred { Predicate::Target(tp) => tp.matches(linux_musl), _ => false, } }));
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,