two proposals for new syntax. #Rust people and general programming folks, what do you think this program should print when `foo` is `Foo::Empty` and `override` is `true`?

unhinged version (overridden is the same as override, a boolean value; i changed the name so it wouldn't highlight as a keyword)


@noracodes Initial reaction: I think you're going for one of these two, but I can't tell which:

/* 1 */ match (if override { Foo::Full(0) } else { foo })

/* 2 */ match (foo) { Foo::Full(value) => {
let value = if override { 0 } else { value }; ... }}

(Having read some other comments in this thread I now believe it's option 1.)

The original two read really weirdly to me and took way too much staring to tell what they do. I read the `where` variant as option 1, and the `let` variant as option 2, but I'm not totally sure of either.

`|| override where` is... ambiguous. I also expect a condition to come *after* `where`, but I don't know off hand if `value = 0 where override` parses unambiguously, and I still don't like it that way.

`where overridden use` reads as unambiguously option 1, but putting that at the end of the block reads weird (and may be way too easy to miss in sufficiently large match blocks). What about `match foo where overridden use Foo::Full(0) {`?

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!