Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-rs latest

FilterExpr.matches

Evaluate this validated expression against candidate.

Source and package
Qualified name
libtmux::query::FilterExpr::matches
Module
query
Declared in
FilterExpr
Package
libtmux
Source
crates/libtmux/src/query.rs
impl<T: Filterable> FilterExpr<T> #[must_use] pub fn matches(&self, candidate: &T) -> bool

Description#

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.

Examples#

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)));
Type parameters
Parameters
Esc

Type to search.

Reference previewOpen reference