Hi,
Am 22.12.2013 um 16:47 schrieb Gábor Lehel <[email protected]>:
> Using `match` works well enough, but if there's demand for a refutable `let`
> which is lighter-weight, what about:
>
> let Some(result) = from_utf8(some_bytes) else fail!();
>
This is a nice idea. At first I thought it wouldn’t work with `if` but in
expressions `if` requires `else` so the grammar wouldn’t be ambiguous:
let Some(result) = if cond { .. } else { … } else fail();
> In other words, if the `let` pattern is refutable, you have to provide
> something `else` with return type `!` as the alternative for when the `let`
> fails to match.
>
Shouldn't the return be the same for all expressions? This would allow:
let Some(result) = from_utf8(some_bytes) else Some(defaultValue);
Stefan.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev