Skip to content

Commit 77d5921

Browse files
committed
Add MultiItemDecorator
1 parent 5769039 commit 77d5921

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/libsyntax/ext/base.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@ impl Annotatable {
150150
}
151151
}
152152

153+
// A more flexible ItemDecorator.
154+
pub trait MultiItemDecorator {
155+
fn expand(&self,
156+
ecx: &mut ExtCtxt,
157+
sp: Span,
158+
meta_item: &ast::MetaItem,
159+
item: &Annotatable,
160+
push: Box<FnMut(P<Annotatable>)>);
161+
}
162+
163+
impl<F> MultiItemDecorator for F
164+
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, Box<FnMut(P<Annotatable>)>)
165+
{
166+
fn expand(&self,
167+
ecx: &mut ExtCtxt,
168+
sp: Span,
169+
meta_item: &ast::MetaItem,
170+
item: &Annotatable,
171+
push: Box<FnMut(P<Annotatable>)>) {
172+
(*self)(ecx, sp, meta_item, item, push)
173+
}
174+
}
175+
153176
// A more flexible ItemModifier (ItemModifier should go away, eventually, FIXME).
154177
// meta_item is the annotation, item is the item being modified, parent_item
155178
// is the impl or trait item is declared in if item is part of such a thing.

0 commit comments

Comments
 (0)