diff options
| author | Adolfo OchagavĂa <aochagavia92@gmail.com> | 2015-01-16 22:59:41 +0100 |
|---|---|---|
| committer | Adolfo OchagavĂa <aochagavia92@gmail.com> | 2015-01-31 11:38:45 +0100 |
| commit | 77d59217a38e2982fdcf6bff800f1c9acc0d9aaf (patch) | |
| tree | 9542c1e3d3b9b3fc323a7c302f8c9e39449889ac /src/libsyntax/ext/base.rs | |
| parent | 57690399a2ab6dd579ea1f97e9866b213f8b14d4 (diff) | |
| download | rust-77d59217a38e2982fdcf6bff800f1c9acc0d9aaf.tar.gz rust-77d59217a38e2982fdcf6bff800f1c9acc0d9aaf.zip | |
Add MultiItemDecorator
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 666e69c2059..edd66b50286 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -150,6 +150,29 @@ impl Annotatable { } } +// A more flexible ItemDecorator. +pub trait MultiItemDecorator { + fn expand(&self, + ecx: &mut ExtCtxt, + sp: Span, + meta_item: &ast::MetaItem, + item: &Annotatable, + push: Box<FnMut(P<Annotatable>)>); +} + +impl<F> MultiItemDecorator for F + where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, Box<FnMut(P<Annotatable>)>) +{ + fn expand(&self, + ecx: &mut ExtCtxt, + sp: Span, + meta_item: &ast::MetaItem, + item: &Annotatable, + push: Box<FnMut(P<Annotatable>)>) { + (*self)(ecx, sp, meta_item, item, push) + } +} + // A more flexible ItemModifier (ItemModifier should go away, eventually, FIXME). // meta_item is the annotation, item is the item being modified, parent_item // is the impl or trait item is declared in if item is part of such a thing. |
