breakable-block 1.0.0

A shim library for a stable implementation of what is proposed in RFC 2046.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 18.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 480.37 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • zedseven/breakable-block
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zedseven

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.