@@ -169,13 +169,14 @@ which contains 232 variants. It would be ridiculous to `pub use` all of them!
169
169
With namespaced enums, this kind of reexport becomes a simple ` pub use ` of the
170
170
enum itself.
171
171
172
- Sometimes a developer wants to use many of an enum's variants, and doesn't want
173
- to require the use of the parent module (in flat enums) or the enum (in
174
- namespaced enums) as part of the name. This is especially common for private,
175
- internal enums within a crate. With flat enums, this requires each enum to be
176
- ` use ` d individually, which can get * extremely* verbose. For example, take
177
- [ this] ( https://github.com/sfackler/rust-postgres/blob/557a159a8a4a8e33333b06ad2722b1322e95566c/src/lib.rs#L97-L136 )
178
- from ` rust-postgres ` :
172
+ Sometimes a developer wants to use many variants of an enum in an "unqualified"
173
+ manner, without qualification by the containing module (with flat enums) or
174
+ enum (with namespaced enums). This is especially common for private, internal
175
+ enums within a crate. With flat enums, this is trivial within the module in
176
+ which the enum is defined, but very painful anywhere else, as it requires each
177
+ variant to be ` use ` d individually, which can get * extremely* verbose. For
178
+ example, take this [ from
179
+ ` rust-postgres ` ] ( https://github.com/sfackler/rust-postgres/blob/557a159a8a4a8e33333b06ad2722b1322e95566c/src/lib.rs#L97-L136 ) :
179
180
``` rust
180
181
use message :: {AuthenticationCleartextPassword ,
181
182
AuthenticationGSS ,
@@ -331,7 +332,7 @@ struct Bar;
331
332
332
333
fn broken (f : Foo ) {
333
334
match f {
334
- Bar => {} // ~ ERROR expected a `Foo` but found struct `Bar`
335
+ Bar => {} // ~ ERROR expected a `Foo` but found type `Bar`
335
336
Baz => {}
336
337
}
337
338
}
@@ -381,10 +382,12 @@ increased complexity comes an increased chance of bugs.
381
382
# Alternatives
382
383
383
384
We can push to switch entirely to namespaced enums before 1.0. This will allow
384
- us to avoid the compatibility fallback, at the cost of adding a significant
385
- amount of work to the 1.0 docket. Given that there is a reasonable post-1.0
386
- path forward, the pain required to push it through before 1.0 does not seem
387
- worth it.
385
+ us to avoid the compatibility fallback and minimize library cruft, at the cost
386
+ of adding a significant amount of work to the 1.0 docket. If we decide to go
387
+ down this route, we could use the same implementation strategy laid out here to
388
+ avoid breaking the entire world at once - implement the fallback and lint at a
389
+ default (or forced) ` warn ` level and then remove both after some period of
390
+ time.
388
391
389
392
Earlier iterations of namespaced enum proposals suggested preserving flat enums
390
393
and adding ` enum mod ` syntax for namespaced enums. However, variant namespacing
0 commit comments