Macro iter

Source
iter!() { /* proc-macro */ }
Expand description

Creates an iterator for the shared reference to a tuple as trait objects.

trait Foo {
    fn bar(&self) -> i32;
}

struct A(i32);
impl Foo for A {
    fn bar(&self) -> i32 { self.0 }
}

struct B(i32);
impl Foo for B {
    fn bar(&self) -> i32 { self.0 }
}

let my_tuple = (A(1), B(2), A(3));
let iter = tuple_iter::iter!(my_tuple, (Foo + Send + Sync + 'static; 3));
let vec: Vec<i32> = iter.map(|foo| foo.bar()).collect();
assert_eq!(vec, vec![1, 2, 3]);