tracing_capture::predicates

Function 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`...