QueryIteratorExt.matching_owned
Lazily move items accepted by matcher, without cloning them.
Source and package
- Qualified name
-
query.Query Iterator Ext .matching _owned - Module
- query
- Declared in
- QueryIteratorExt
- Package
- libtmux
- Source
- crates/libtmux/src/query.rs
-
Description#
The matcher borrows each item for the comparison. Use
Self::matchingwithiter()to retain a borrow of each item. OrdinaryIterator::filteralso 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");