#syntax

macro for_let

Syntax sugar for a for-loop + pattern binding

1 unstable release

0.1.0 Dec 22, 2022

#298 in #syntax

MIT license

8KB

for_let

That one syntax sugar library you (may have) wished you wrote yourself.

This library provides the for_let! macro, so you can write code like this:

for_let!(Some(Complex(Pattern(foo))) in iteratee {
    // do stuff
});

Which is just sugar for this:

for el in iteratee {
    match el {
        Some(Complex(Pattern(foo))) => {
            // do stuff
        }
        _ => {}
    }
}

Accepts all patterns that are legal in a match arm. How Pythonic!

Dependencies

~1.5MB
~36K SLoC