easy-plugin 0.9.0

A compiler plugin that makes it easier to write compiler plugins.
docs.rs failed to build easy-plugin-0.9.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: easy-plugin-0.11.7

easy-plugin

crates.io Travis CI

A compiler plugin that makes it easier to write compiler plugins.

Released under the Apache License 2.0.

Supported Configurations

By default, easy-plugin expects to be compiled by a nightly Rust compiler. easy-plugin is also supported on the stable and beta channels of Rust with syntex. To enable this support, enable the stable Cargo feature.

Example

easy_plugin! {
    struct Arguments {
		// An argument specification that accepts a simple binary expression.
    	$a:ident $operator:binop $b:ident
    }

    // The `arguments: Arguments` argument contains the parsed results of the
    // plugin arguments according to the above specification. An error is reported
    // if the plugin arguments cannot be parsed.
    pub fn expand_plugin(
        context: &mut ExtCtxt, span: Span, arguments: Arguments
    ) -> PluginResult<Box<MacResult>> {
    	// Accesses the parsed results.
        println!("{:?} {:?} {:?}", arguments.a, arguments.operator, arguments.b);

        // Returns `Ok` to signal this plugin completed successfully. An error is
        // reported if `Err` is returned instead.
        Ok(DummyResult::any(span))
    }
}

#[plugin_registrar]
pub fn plugin_registrar(registry: &mut Registry) {
    registry.register_macro("plugin", expand_plugin);
}