# query.FilterExpr.matches

- **Module:** query.FilterExpr
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/query.rs#L1228
- **Page:** https://libtmux.org/en/rs/latest/reference/query-filterexpr-matches/

```
query.FilterExpr.matches(self, candidate: &T) -> bool
```

Evaluate this validated expression against `candidate`.

Evaluation is infallible, ordered, and short-circuiting. Every text
predicate first requires strict candidate UTF-8 and returns `false` for
invalid bytes, including empty exclusion. An outer [`Self::not`] can
invert that result.

## Example

```rust
use libtmux::query::{BoolField, FilterExpressionError, Filterable};
use libtmux::query::__private::{self, Predicate};

struct Task(bool);
struct Fields(BoolField<Task>);

impl Filterable for Task {
    type Fields = Fields;
    const FILTER_TARGET: &'static str = "task";

    fn filter_fields() -> Self::Fields {
        Fields(__private::bool_field(Self::FILTER_TARGET, "done"))
    }

    fn __filter_matches(&self, predicate: &Predicate) -> bool {
        predicate.matches_bool(self.0)
    }

    fn __filter_validate(_: &Predicate) -> Result<(), FilterExpressionError> {
        Ok(())
    }
}

let expression = Task::filter_fields().0.eq(true);
assert!(expression.matches(&Task(true)));
```
