Core LibraryalphaAPI Reference

Choose documentation 3

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

method libtmux-rs latest

QueryIteratorExt.matching_owned

Lazily move items accepted by matcher, without cloning them.

Source and package
Qualified name
query.QueryIteratorExt.matching_owned
Module
query
Declared in
QueryIteratorExt
Package
libtmux
Source
crates/libtmux/src/query.rs
#[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>

Description#

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#

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
Parameters
Esc

Type to search.

Reference preview Open reference