#error #try #catch #result #options

macro break-block-macro

A little syntactic sugar to tide us over until the ? operator can be used to exit try-catch scopes

1 unstable release

0.1.0 Apr 29, 2024

#1594 in Rust patterns

Download history 136/week @ 2024-04-26 12/week @ 2024-05-03

148 downloads per month

MIT/Apache

4KB

break-block-macro

A little syntactic sugar to tide us over until the ? operator can be used to exit try-catch scopes

The bb macro behaves like the ? operator, but will break out of labeled scopes to achieve something that resembles try-catch.

See this issue for background.

Usage

use break_block_macro::bb;

let result = 'block: {
    let one = bb!(Ok("one"));
    assert_eq!(one, "one");

    let _two = bb!(Err("two"));
    Ok("three")
};
assert_eq!(result, Err("two"));

Dependencies

~86KB