A question / proposed syntax... How about allowing writing something like:

    if (Some(foo), Some(bar)) ~~ (get_option("foo"), get_option("bar)) {
        use(foo, bar);
    }

Instead of having to write the more combersome:

    match (get_option("foo"), get_option("bar")) {
        (Some(foo), Some(bar)) => {
            use(foo, bar);
        },
        _otherwise => {},
    }

Not to mention:

    let foo_bar: bool = (Some(_foo), Some(_bar)) ~~ (get_option("foo"),
get_option("bar"));

    match (get_option("foo"), get_option("bar")) {
        (Some(foo), Some(bar)) => {
            use(foo, bar);
        },
        _otherwise => {},
    }

Instead of the very cumbersome:

    let foo_bar: bool =
        match (get_option("foo"), get_option("bar")) {
            (Some(_foo), Some(_bar)) => true,
            _otherwise => false,
        }
    }

So, in general allow `pattern ~~ expression` to be a boolean expression and
if it is used in an "if" statement allow it to introduce the matched
variables to the "then" scope.

The operator doesn't have to be ~~, it could be anything unique (though
using ~ for matching has a lot of precedence in other languages).

Thoughts?

Oren Ben-Kiki
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to