Skip to content

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

License

Notifications You must be signed in to change notification settings

abonander/enum_ns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

#![feature(phase)]
#![promote_variants]

#[phase(plugin)] extern crate enum_ns;

enum MyEnum {
    Variant1,
    Variant2,
    Variant3,
}

fn main() {
  println!("{}, {}, {}", Variant1, Variant2, Variant3);
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages