1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use weedle::common::Generics;
use weedle::interface::*;
use weedle::term::Comma;
use weedle::types::*;

/// A WebIDL symbol with generic types
pub trait SymbolWithGenerics {
	type GenericType;
	fn generics(self) -> Generics<Self::GenericType>;
}

macro_rules! impl_symbol_with_generics {
	($($sym:ident | $t: ty),+ $(,)?) => {
		$(
			impl<'a> SymbolWithGenerics for $sym<'a> {
				type GenericType = $t;
				fn generics(self) -> Generics<Self::GenericType> {
					self.generics
				}
			}
		)+
	};
}

impl_symbol_with_generics!(
	SingleTypedIterable | AttributedType<'a>,
	DoubleTypedIterable | (AttributedType<'a>, Comma, AttributedType<'a>),
	SingleTypedAsyncIterable | AttributedType<'a>,
	DoubleTypedAsyncIterable | (AttributedType<'a>, Comma, AttributedType<'a>),
	MaplikeInterfaceMember | (AttributedType<'a>, Comma, AttributedType<'a>),
	SetlikeInterfaceMember | AttributedType<'a>,
	SequenceType | Box<Type<'a>>,
	FrozenArrayType | Box<Type<'a>>,
	PromiseType | Box<ReturnType<'a>>,
	RecordType | (Box<RecordKeyType<'a>>, Comma, Box<Type<'a>>),
);