rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.95k stars 362 forks source link

Updated extensibility to discuss non_exhaustive #135

Closed rcoh closed 2 years ago

rcoh commented 3 years ago

A first cut at discussing how #[non_exhaustive] should be used.

Fixes #132

pickfire commented 3 years ago

I only see that the advantages being mentioned but not the disadvantages. Most of the time I see this as unnecessary because it prevents the compiler from doing its job to check that the developer handle all the fields. This could be one example, in most cases having a breaking change by adding a new field to an enum is better than using #[non_exhaustive] as the user may not even notice that there is a new field if they want to handle all fields.

Maybe we should have a good example on both decisions and when to apply (or not to) them.

rcoh commented 3 years ago

I've fleshed out the discussion some more although I think there's still a bit more to do

simonsan commented 3 years ago

@pickfire @MarcoIeni Want to give it a read as well?

@rcoh What did you want to add to it still? Or is it fine from your side now?

rcoh commented 3 years ago

good from my side

simonsan commented 3 years ago

@rcoh I think only the last review comment is left and fixing the doc test and then we're good to go! :)

HKalbasi commented 3 years ago

Seems @rcoh lost interest on this. Can a team member finish it? It's a pity that the old article is online while this is almost ready.

simonsan commented 3 years ago

Seems @rcoh lost interest on this. Can a team member finish it? It's a pity that the old article is online while this is almost ready.

Should be fine now, @MarcoIeni @pickfire might want to read over it once more so we can merge it.

simonsan commented 2 years ago

Thank you everyone. :)