BurntSushi / regex-automata

A low level regular expression library that uses deterministic finite automata.
The Unlicense
351 stars 26 forks source link

Replace `#[doc(hidden)] __Nonexhaustive` with `#[non_exhaustive]` #9

Closed aDotInTheVoid closed 4 years ago

aDotInTheVoid commented 4 years ago

Using the #[non_exhaustive], you can remove the __Nonexhaustive varient of DenseDFA and SparseDFA.

Advantages:

Disadvantages

This will not break code that has wildcard arm in all matches (which is must unless it explicitly matches against __Nonexhaustive in which case it will be broken if and when more variants are added. However, it will break codebases that compile with rust 1.39 or lower.

BurntSushi commented 4 years ago

The MSRV bump alone is enough to disqualify this, sorry. Moreover, IMO you have missed a really critical disadvantage: the __Nonexhaustive variant permits crate internal implementations to do exhaustive case analysis.

The final nail in the coffin is that this enum will go away in the 0.2 release. See #7.

aDotInTheVoid commented 4 years ago

The MSRV bump alone is enough to disqualify this, sorry.

Totaly understood

the __Nonexhaustive variant permits crate internal implementations to do exhaustive case analysis.

So does #[non_exhaustive]. To quote the RFC

Within the crate that defines the enum, this attribute is essentially ignored, so that the current crate can continue to exhaustively match the enum.

Outside the crate that defines the enum, users should be required to add a wildcard arm to ensure forward-compatibility

This is not an argument for reopening the pull, but I just thaught you should know, as it's a realy well designed feature.

BurntSushi commented 4 years ago

Oh that's interesting! I did not know about that. Thank you for correcting me!