with_id

Function with_id 

Source
pub fn with_id<F>(f: F) -> WithId<F>
Expand description

Passes the identifier to the function.

Function traits that implement this trait allow to pass a function that receives the identifier of the item as the first argument. This is useful when the function needs to know the identifier of the item being processed, which is necessary in certain contexts.

Note that there are no trait bounds, since [WithId] is merely a marker struct that is used to differentiate between function implementations. This is also why the returned type implements Deref, so that it behaves like the underlying function.

ยงExamples

use zrx_stream::function::{with_id, InspectFn};

// Define and execute function
let f = |&id: &&str, &n: &i32| println!("{id} -> {n}");
with_id(f).execute(&"id", &42)?;