webidl_utils/symbol/
with_generics.rs1use weedle::common::Generics;
2use weedle::interface::*;
3use weedle::term::Comma;
4use weedle::types::*;
5
6pub trait SymbolWithGenerics {
8 type GenericType;
9 fn generics(self) -> Generics<Self::GenericType>;
10}
11
12macro_rules! impl_symbol_with_generics {
13 ($($sym:ident | $t: ty),+ $(,)?) => {
14 $(
15 impl<'a> SymbolWithGenerics for $sym<'a> {
16 type GenericType = $t;
17 fn generics(self) -> Generics<Self::GenericType> {
18 self.generics
19 }
20 }
21 )+
22 };
23}
24
25impl_symbol_with_generics!(
26 SingleTypedIterable | AttributedType<'a>,
27 DoubleTypedIterable | (AttributedType<'a>, Comma, AttributedType<'a>),
28 SingleTypedAsyncIterable | AttributedType<'a>,
29 DoubleTypedAsyncIterable | (AttributedType<'a>, Comma, AttributedType<'a>),
30 MaplikeInterfaceMember | (AttributedType<'a>, Comma, AttributedType<'a>),
31 SetlikeInterfaceMember | AttributedType<'a>,
32 SequenceType | Box<Type<'a>>,
33 FrozenArrayType | Box<Type<'a>>,
34 PromiseType | Box<ReturnType<'a>>,
35 RecordType | (Box<RecordKeyType<'a>>, Comma, Box<Type<'a>>),
36);