do-notation icon indicating copy to clipboard operation
do-notation copied to clipboard

optionally drop the move keyword?

Open aavogt opened this issue 2 years ago • 0 comments

In a block like:

fn update(&mut self) {
m! {
    guard(self.grabbing);
    let del = input_state.pointer.delta();
    guard(del.x != 0.0 || del.y != 0.0);
    x <- pointer_hover_frac(input_state);
    Some(self.add_pos2(x))
};
// I want to use self here but it's gone
}

Perhaps p <= e could desugar to e.and_then(move |p| while p <- e could be changed to e.and_then(|p|? Ideally it would be possible to use the move keyword only when there is a semicolon, but at first glance it doesn't look like a macro can know about layout or indentation.

aavogt avatar Feb 24 '23 19:02 aavogt