commit | 15085c417ec803cd0987f2ef3c3e7f58a7393023 | [log] [tgz] |
---|---|---|
author | Sean Griffin <sean@seantheprogrammer.com> | Mon Oct 03 11:40:31 2016 -0400 |
committer | David Tolnay <dtolnay@gmail.com> | Mon Oct 03 09:13:06 2016 -0700 |
tree | 62ce84036d761d7b73fc07bee20cde2561ade9ce | |
parent | 176d8a972b7f7c684245c9bd94339b8c80e7a2c1 [diff] |
Add `VariantData#fields_mut` This adds the mutable equivalent to `VariantData#fields`, and can make code which needs to mutate those fields a bit less verbose.
Parse Rust structs and enums without a Syntex dependency, intended for use with Macros 1.1.
Designed for fast compile time.
syn
(from scratch including all dependencies): 4 secondssyntex
/quasi
/aster
stack: 60+ seconds[dependencies] syn = "0.8" quote = "0.2" [lib] rustc-macro = true
#![feature(rustc_macro, rustc_macro_lib)] extern crate rustc_macro; use rustc_macro::TokenStream; extern crate syn; #[macro_use] extern crate quote; #[rustc_macro_derive(MyMacro)] pub fn my_macro(input: TokenStream) -> TokenStream { let source = input.to_string(); // Parse a string of items to an AST let ast = syn::parse_macro_input(&source).unwrap(); // Build the output, possibly using quasi-quotation let expanded = quote! { // ... }; // Parse this back to a token stream and return it expanded.to_string().parse().unwrap() }
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.