Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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 2 months ago
JSON representation

A Rust compiler plugin that gives enum variants within a module the old namespacing behavior.

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);
}