How to rewrite what follows to have it all in one line, in function signature:
fn process(tup: &mut (u32,u32,&mut image::Luma<u8>)) { let &mut (x,y, _) = tup; let ref mut pixel = *tup.2; I got as far as:
fn process(&mut (x,y, ref mut pixel): &mut (u32,u32,&mut image::Luma<u8>)) { but that's not exact equivalent because I no longer can do:
*pixel = image::Luma([i as u8]); inside the function, that I could do when I had temporary tup binding.
Fails with:
src\main.rs:43:14: 43:36 note: expected type `&mut image::Luma<u8>` src\main.rs:43:14: 43:36 note: found type `image::Luma<u8>` I also tried:
process(&mut (x, y, pixel): &mut (u32,u32,&mut image::Luma<u8>)) but this fails with:
src\main.rs:23:12: 23:29 error: cannot move out of borrowed content [E0507] src\main.rs:23 fn process(&mut (x,y, pixel): &mut (u32,u32,&mut image::Luma<u8>)) { ^~~~~~~~~~~~~~~~~ src\main.rs:23 fn process(&mut (x,y, pixel): &mut (u32,u32,&mut image::Luma<u8>)) { ^~~~~ Basically what I need is pattern that can destructure reference to borrowed value from a borrow.
process((x, y, pixel): (u32, u32, &mut X)). The outer&mut(on both sides) is useless here.src\main.rs:72:33: 72:34 note: expected type (u32, u32, &mut image::Luma<u8>) src\main.rs:72:33: 72:34 note: found type &mut (u32, u32, &mut _)I also can't deference at the call site becausecannot move out of borrowed content. Would work if tuple third element wasn't a borrow.