Macro iter_mut

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

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

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

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

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

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