mkhan45 / RustScript2

RustScript is a functional scripting language with as much relation to Rust as Javascript has to Java.
https://mkhan45.github.io/RustScript2/
Other
36 stars 2 forks source link

if let block for refutable bindings #52

Closed mkhan45 closed 2 years ago

mkhan45 commented 2 years ago

e.g.

    let %{
        "type" => type,
        "title" => title,
        "url" => url,
        "password" => password
    } = gen_state(:body) |> parse_urlencoded

This line fails if gen_state(:body) doesn't match the pattern, crashing the program. Instead, I should be able to use:

    with let %{
        "type" => type,
        "title" => title,
        "url" => url,
        "password" => password
    } = gen_state(:body) |> parse_urlencoded {
        } else {
            ....
        }