Proposal: Bounded continuations - non-local control flow without the mess

My concern is this:

fn do_thing<F>(f: F) where F: FnOnce() {
    begin_something();
    f();
    finish_something();
}

(Usually, this is in the context of temporarily breaking apart some value into multiple, disjoint borrows.)

With this, the call to finish_something() can be skipped without panicking. I don't see how you can introduce a totally new form of non-local control flow without breaking code like this.

Unless you do what panic! does and taint/destroy everything it unwinds through... but then we're back to "how is this different to panic!?"

1 Like