macro_rules! with_hash {
($items:expr, $hash_fn:expr, $body:expr) => { ... };
}Expand description
Wraps items in WithContext<T, HashContext<T>> with
a custom hash function, runs a callback, and provides the wrapped slice.
ยงExamples
use context_trait::{with_hash, WithContext, HashContext};
use std::hash::Hasher;
let items = vec![(1, 100), (1, 200), (2, 300)];
with_hash!(items, |v: &(i32, i32), h: &mut dyn Hasher| { h.write_i32(v.0); },
|wrapped: &[WithContext<(i32, i32), HashContext<(i32, i32)>>]| {
let _: Vec<_> = wrapped.to_vec();
});