Hello everyone, I'm trying to make something like this:
let iter = my_struct.iter::<(A, B)>();
while let Some((a, b)) = iter.next() {}
The tuple can be (&T, &U), (&mut T, &U), (&T, &mut U) or (&mut T, &mut U) and iter.next() has to borrow from itself.
Given these requirements I can't use std's Iterator but it's not a big deal. This article presents 3.5 ways to make an iterator borrowing from itself, the last one is nightly only and doesn't work well with what I'm trying to do so I tried the first 2.5.
My issue is that I can't get the right lifetime, I only get my_struct's lifetime.
I don't even know if that's possible, I made it work by using a macro that basically counted in binary (since mut can be thought as 1 and no mut as 0) but I generated so much code it took 50sec to build with tuples only going to size 6.
This is the closest I got using method 2.5.
Like I said, I don't know if it's possible. If a lifetime wizard could tell me and maybe point me to the right direction it would be awesome.
Thank you.