Trait tuplez::ForeachMut
source · pub trait ForeachMut<F>: TupleLike {
type Output: TupleLike;
// Required method
fn foreach_mut(&mut self, f: &mut F) -> Self::Output;
}Expand description
Traverse the tuple by mutable references to its elements.
§The Functor F
For traversing Tuple<T0, T1, ... Tn>, you need to construct a custom functor type,
which needs to implement MapperMut<T0>, MapperMut<T1> … MapperMut<Tn>.
See the documentation page of MapperMut for details.
Required Associated Types§
Required Methods§
sourcefn foreach_mut(&mut self, f: &mut F) -> Self::Output
fn foreach_mut(&mut self, f: &mut F) -> Self::Output
Traverse the tuple by mutable references to its elements, and collect the output of traversal into a new tuple.
§Example
use tuplez::*;
let mut tup = tuple!(2, "hello", 3.14);
let tup2 = tup.foreach_mut(mapper_mut!{
x: i32: { (*x) *= (*x); *x - 1 };
x: f32 => (): *x += 1.0;
x, 'a: &'a str: *x
});
assert_eq!(tup, tuple!(4, "hello", 3.14 + 1.0));
assert_eq!(tup2, tuple!(3, "hello", ()));Object Safety§
This trait is not object safe.