Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ ast_types! {
/// Parses `record<StringType, Type>`
struct RecordType<'a> {
record: term!(record),
generics: Generics<(StringType, term!(,), Box<Type<'a>>)>,
generics: Generics<(Box<RecordKeyType<'a>>, term!(,), Box<Type<'a>>)>,
}

/// Parses one of the string types `ByteString|DOMString|USVString`
#[derive(Copy)]
enum StringType {
/// Parses one of the string types `ByteString|DOMString|USVString` or any other type.
enum RecordKeyType<'a> {
Byte(term!(ByteString)),
DOM(term!(DOMString)),
USV(term!(USVString)),
NonAny(NonAnyType<'a>),
}

/// Parses one of the member of a union type
Expand Down Expand Up @@ -242,7 +242,7 @@ mod test {
);

test_variants!(
StringType {
RecordKeyType {
DOM == "DOMString",
USV == "USVString",
Byte == "ByteString"
Expand All @@ -254,6 +254,11 @@ mod test {
RecordType;
});

test!(should_parse_record_type_alt_types { "record<u64, short>" =>
"";
RecordType;
});

test!(should_parse_double_type { "double" =>
"";
DoubleType;
Expand Down