Function tracing_capture::predicates::into_fn

source ·
pub fn into_fn<Item>(predicate: impl Predicate<Item>) -> impl Fn(&Item) -> bool
Expand description

Converts a predicate into an Fn(_) -> bool closure.

This can be used in APIs (e.g., Iterator combinators) that expect a closure as an argument.

§Examples

let predicate = into_fn(target("tracing") & level(Level::INFO));
let events: &[CapturedEvent] = // ...
let matching_events = events.iter().copied().filter(predicate);
// Do something with `matching_events`...