Match ergonomics 2024 poll

It only sorts by popularity on the "show results" page

The "or" option means both let [&x] = &[&mut 42] and let &[x] = &[&mut 42]; should work. The "both" option means all 3 examples should work.

Explicit array patterns should not match a reference ever. Thus, neither should work.

1 Like

So you would prefer to eliminate match ergonomics entirely?

No, I prefer if array patterns only match arrays, not slices and arrays.

&[&mut 42] is a reference to an array of length 1, it is not a slice.

1 Like

That would be my preference. Match ergonomics is optimized for writing rather than reading. More complicated rules make it worse.

1 Like

True, poor wording on my part. Not sure why I used "slices" this time. Anyway, I kinda sympathize with @tczajka's point, but I am mostly indifferent, to be honest. I was fine before Rust had match ergonomics, and while it improved things for me a bit, the improvement wasn't that big, so if this feature were removed tomorrow for some realistic reason, I wouldn't throw a tantrum and ditch Rust for good.

1 Like