Parse closure movability
diff --git a/src/expr.rs b/src/expr.rs
index 2bd1099..11cee91 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -313,6 +313,7 @@
/// *This type is available if Syn is built with the `"full"` feature.*
pub Closure(ExprClosure #full {
pub attrs: Vec<Attribute>,
+ pub movability: Option<Token![static]>,
pub capture: Option<Token![move]>,
pub or1_token: Token![|],
pub inputs: Punctuated<FnArg, Token![,]>,
@@ -1967,6 +1968,7 @@
#[cfg(feature = "full")]
named!(expr_closure(allow_struct: bool) -> Expr, do_parse!(
+ movability: option!(keyword!(static)) >>
capture: option!(keyword!(move)) >>
or1: punct!(|) >>
inputs: call!(Punctuated::parse_terminated_with, fn_arg) >>
@@ -1987,6 +1989,7 @@
) >>
(ExprClosure {
attrs: Vec::new(),
+ movability: movability,
capture: capture,
or1_token: or1,
inputs: inputs,
@@ -3106,6 +3109,7 @@
impl ToTokens for ExprClosure {
fn to_tokens(&self, tokens: &mut Tokens) {
tokens.append_all(self.attrs.outer());
+ self.movability.to_tokens(tokens);
self.capture.to_tokens(tokens);
self.or1_token.to_tokens(tokens);
for input in self.inputs.pairs() {
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index e30906f..3676070 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -1077,6 +1077,7 @@
pub fn fold_expr_closure<V: Fold + ?Sized>(_visitor: &mut V, _i: ExprClosure) -> ExprClosure {
ExprClosure {
attrs: FoldHelper::lift(_i . attrs, |it| { _visitor.fold_attribute(it) }),
+ movability: (_i . movability).map(|it| { Token ! [ static ](tokens_helper(_visitor, &(it).0)) }),
capture: (_i . capture).map(|it| { Token ! [ move ](tokens_helper(_visitor, &(it).0)) }),
or1_token: Token ! [ | ](tokens_helper(_visitor, &(_i . or1_token).0)),
inputs: FoldHelper::lift(_i . inputs, |it| { _visitor.fold_fn_arg(it) }),
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index abe2820..c42740a 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -848,6 +848,7 @@
# [ cfg ( feature = "full" ) ] # [ cfg ( any ( feature = "full" , feature = "derive" ) ) ]
pub fn visit_expr_closure<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprClosure) {
for it in & _i . attrs { _visitor.visit_attribute(it) };
+ if let Some(ref it) = _i . movability { tokens_helper(_visitor, &(it).0) };
if let Some(ref it) = _i . capture { tokens_helper(_visitor, &(it).0) };
tokens_helper(_visitor, &(& _i . or1_token).0);
for el in Punctuated::pairs(& _i . inputs) { let it = el.value(); _visitor.visit_fn_arg(it) };
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index fcb842a..44e6e35 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -849,6 +849,7 @@
# [ cfg ( feature = "full" ) ] # [ cfg ( any ( feature = "full" , feature = "derive" ) ) ]
pub fn visit_expr_closure_mut<V: VisitMut + ?Sized>(_visitor: &mut V, _i: &mut ExprClosure) {
for it in & mut _i . attrs { _visitor.visit_attribute_mut(it) };
+ if let Some(ref mut it) = _i . movability { tokens_helper(_visitor, &mut (it).0) };
if let Some(ref mut it) = _i . capture { tokens_helper(_visitor, &mut (it).0) };
tokens_helper(_visitor, &mut (& mut _i . or1_token).0);
for mut el in Punctuated::pairs_mut(& mut _i . inputs) { let it = el.value_mut(); _visitor.visit_fn_arg_mut(it) };