From 90031e37d491104b9cd9572e7c3d6d214da39fa0 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 25 Nov 2021 12:06:13 +0100 Subject: [PATCH] Allow any type as the key type in records --- src/types.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/types.rs b/src/types.rs index c8952a6..913c307 100644 --- a/src/types.rs +++ b/src/types.rs @@ -120,15 +120,15 @@ ast_types! { /// Parses `record` struct RecordType<'a> { record: term!(record), - generics: Generics<(StringType, term!(,), Box>)>, + generics: Generics<(Box>, term!(,), Box>)>, } - /// 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 @@ -242,7 +242,7 @@ mod test { ); test_variants!( - StringType { + RecordKeyType { DOM == "DOMString", USV == "USVString", Byte == "ByteString" @@ -254,6 +254,11 @@ mod test { RecordType; }); + test!(should_parse_record_type_alt_types { "record" => + ""; + RecordType; + }); + test!(should_parse_double_type { "double" => ""; DoubleType;