https://github.com/abonander/enum_ns
A Rust compiler plugin that gives enum variants within a module the old namespacing behavior.
https://github.com/abonander/enum_ns
Last synced: about 1 month ago
JSON representation
A Rust compiler plugin that gives enum variants within a module the old namespacing behavior.
- Host: GitHub
- URL: https://github.com/abonander/enum_ns
- Owner: abonander
- License: mit
- Created: 2014-11-25T04:11:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-25T04:26:19.000Z (almost 11 years ago)
- Last Synced: 2025-06-17T19:04:50.774Z (5 months ago)
- Language: Rust
- Size: 211 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
enum_ns
==========
A Rust compiler plugin that gives enum variants within a module the old namespacing behavior.
Supplies the `#[promote_variants]` attribute that, when applied to a crate or module, will add `use Enum::{Variant1, Variant2, ..};` to the module for each `enum` definition it contains. For forward-compatibility, does not use globs.
Apply the `#[promote_variants(export)]` for the equivalent `pub use` of the above.
Usage
--------
Add to Cargo.toml:
```
[dependencies.enum_ns]
git = "https://github.com/cybergeek94/enum_ns"
```
Crate example:
```rust
#![feature(phase)]
#![promote_variants]
#[phase(plugin)] extern crate enum_ns;
enum MyEnum {
Variant1,
Variant2,
Variant3,
}
fn main() {
println!("{}, {}, {}", Variant1, Variant2, Variant3);
}