breakable-block

Crates.iobreakable-block
lib.rsbreakable-block
version1.0.0
sourcesrc
created_at2021-11-06 21:16:05.750299
updated_at2021-11-06 21:16:05.750299
descriptionA shim library for a stable implementation of what is proposed in RFC 2046.
homepagehttps://github.com/zedseven/breakable-block
repositoryhttps://github.com/zedseven/breakable-block
max_upload_size
id477843
size19,192
Zacchary Dempsey-Plante (zedseven)

documentation

README

breakable-block

License: MIT/Apache-2.0 # Issues Crates.io Crate Downloads

A shim library for a stable implementation of what is proposed in RFC 2046, allowing for short-circuit control flow without needing to return in a function or break in a loop.

When the RFC is stabilized, this crate will be deprecated. If you don't need to work on stable, you can use

#![feature(label_break_value)]

in your crate root to enable the functionality instead.

This crate has no dependencies.

How to Use It

Here's an example, lifted straight from the RFC documentation with only minor modifications:

use breakable_block::breakable;

breakable!('block: {
    do_thing();
    if condition_not_met() {
        break 'block;
    }
    do_next_thing();
    if condition_not_met() {
        break 'block;
    }
    do_last_thing();
});

The only difference in syntax from the example in the RFC is the wrapping macro call.

Project License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in breakable-block by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 2

cargo fmt