11 unstable releases (3 breaking)

Uses old Rust 2015

0.4.1 Mar 8, 2017
0.4.0 Feb 22, 2017
0.3.6 Dec 7, 2016
0.3.5 Oct 22, 2016
0.1.0 Jul 27, 2016

#1155 in Data structures

Download history 39/week @ 2024-02-25 10/week @ 2024-03-03 115/week @ 2024-03-31

115 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

47KB
946 lines

synthax

crates.io Travis CI

Documentation

Synthesize syntax with quasiquoting plugins.

Released under the Apache License 2.0.

See CONTRIBUTING.md for guidelines on contributing to this repository.


lib.rs:

Synthesize syntax with quasiquoting plugins.

The quasiquoting plugins supplied by this crate behave like those supplied by libsyntax (i.e., #![feature(quote)]) with two differences.

First, the results of expressions can be quoted directly without intermediate variables by enclosing the expression in ${..}. For example, to quote the first element of the slice tokens, write ${tokens[0]}.

let tokens = &[Token::Eq, Token::Semi];
let stmt = quote_stmt!(context, let foo ${tokens[0]} bar ${tokens[1]});

Second, slices and Vecs containing quotable values can be quoted in sequences. The sequences are written like and behave like the sequences in macros. For example, to quote the values of the slice idents with , between each quoted value, write $($ident), *.

let idents = &[context.ident_of("foo"), context.ident_of("bar"), context.ident_of("baz")];
let pat = quote_pat!(context, Struct { $(ref $idents), * });
let pat = quote_pat!(context, Struct { $(ref mut ${&idents[..1]}), * });

Plugins

  • quote_token_trees!
  • quote_arg!
  • quote_arm!
  • quote_attribute!
  • quote_bare_fn_ty!
  • quote_block!
  • quote_expr!
  • quote_field!
  • quote_field_pat!
  • quote_fn_decl!
  • quote_foreign_item!
  • quote_foreign_mod!
  • quote_generics!
  • quote_impl_item!
  • quote_item!
  • quote_lifetime!
  • quote_lit!
  • quote_local!
  • quote_meta_item!
  • quote_pat!
  • quote_path!
  • quote_stmt!
  • quote_struct_field!
  • quote_trait_item!
  • quote_ty!
  • quote_variant!
  • quote_where_clause!

Dependencies