# query.QueryIteratorExt.matching_owned

- **Module:** query
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/84de9258a07d10bdd5f6da01b016a9ae06fe1210/crates/libtmux/src/query.rs#L551
- **Page:** https://libtmux.org/en/rs/latest/reference/query-queryiteratorext-matching_owned/

```
#[allow(clippy::module_name_repetitions)]
pub trait QueryIteratorExt: Iterator + Sized
fn matching_owned<M: Matcher<Self::Item>>(
    self,
    matcher: M,
) -> impl Iterator<Item = Self::Item>
```

Lazily move items accepted by `matcher`, without cloning them.

The matcher borrows each item for the comparison. Use
[`Self::matching`] with `iter()` to retain a borrow of each item.
Ordinary [`Iterator::filter`] also accepts closures and infers their
argument types; closures passed here need an explicit argument type.

## Examples

```rust
use libtmux::query::QueryIteratorExt;

let names = vec![String::from("build"), String::from("test")];
let selected = names
    .into_iter()
    .matching_owned(|name: &String| name.starts_with('b'))
    .exactly_one()?;
assert_eq!(selected, "build");
```

## Type parameters

- `M` (bound `Matcher<Self::Item>`)

## Parameters

- `matcher` (`M`)
