Struct filter_ast::Tree[][src]

pub struct Tree<T> { /* fields omitted */ }
Expand description

A compound node in a filter expression, consisting of a logical operator and a set of child expressions.

Implementations

Decompose the tree into its operator and rules.

Create an instance by collecting the rules from an iterator.

Example
let rules = vec![
    Clause::new("name", "=", "jim"),
    Clause::new("age", ">", "10")
];

let tree = Tree::from_iter(
    Logic::And,
    rules.into_iter().filter(|f| *f.field() != "age")
);

assert_eq!(1, tree.rules().len());

Create a new tree by applying a transform to all its rules.

Example
let tree = Tree::new(Logic::Or, vec![1, 2]);
let tree2 = tree.map(|x| x * 10);
assert_eq!(Tree::new(Logic::Or, vec![10, 20]), tree2);

Create a new tree by applying a fallible transform to all its rules. The function will return the first error it encounters.

Example
let tree = Tree::new(Logic::Or, vec![1, 2]);
let tree2 = tree.try_map(|x| {
    if x % 2 == 0 {
        Ok(x * 10)
    } else {
        Err(format!("Odd number: {}", x))
    }
});
assert_eq!("Odd number: 1", &tree2.unwrap_err());

Sort the rules in the tree.

Trait Implementations

The resulting type after applying the & operator.

Performs the & operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.