Excerpts from Huon Wilson's message of 2013-12-06 00:26:36 -0800: > One could have an Iterator<(&mut int, &mut int)>, where the references > point to just the fields. Off the top of my head:
Sure. (This is not so good when there are a lot of fields.) > impl<'a> Iterator<(&'a mut int, &'a mut f64)> for ListMutIterator<'a> { > fn next(&mut self) -> Option<(&'a mut int, &'a mut f64)> { > let elem = std::util::replace(self, None); // I think this > might be necessary to get around the borrow checker. > > let (ret, next) = match elem { > Some(&List { payload1: ref mut payload1, next: ref mut > next, payload2: ref mut payload2 }) => { > (Some((payload1, payload2)), next.as_mut_ref()) I fixed some of the egregious type-checking errors, but this one has me stuck. There is no as_mut_ref() in the version of Rust I'm running, and the plausible replacement mut_ref() doesn't do what I want: Huon.rs|24 col 37 error| mismatched types: expected `std::option::Option<&mut List>` but found `std::option::Option<&mut ~List>` (expected struct List but found ~-ptr) (Because, of course, the thing inside the option is a ~List, not a List). Cheers, Edward _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev