Pre-RFC: attempt! macro

If we could figure out a clean way to support an outer return this pattern would fall out naturally.

let something = something.unwrap_or_else(|| {
    eprintln!("Oh no, something failed D:");
    eprintln!("Try taking a glass of water and trying again!");
    
    // return from captured fn (other syntax ideas were proposed in the thread)
    // I like this one the best as it resembles break labels
    return 'fn;
});

I opened an internal thread on that here: pre-RFC: Allow return, continue, and break to affect the captured environment

1 Like