diff --git a/lang/rs/converter/src/alias.rs b/lang/rs/converter/src/alias.rs index d20c3c8..a208c7b 100644 --- a/lang/rs/converter/src/alias.rs +++ b/lang/rs/converter/src/alias.rs @@ -26,6 +26,12 @@ impl RSConvert for GTAlias { RSDefinition::Struct(object.convert(context)?) } + GTDescriptor::Branded(branded) => { + context.provide_definition_id(self.id.clone()); + context.provide_doc(doc); + RSDefinition::Struct(branded.convert(context)?) + } + GTDescriptor::Union(union) => { context.provide_definition_id(self.id.clone()); context.provide_doc(doc); @@ -140,6 +146,37 @@ mod tests { ); } + #[test] + fn test_convert_branded() { + assert_eq!( + GTAlias { + id: GTDefinitionId("module".into(), "BookId".into()), + span: (0, 0).into(), + doc: None, + attributes: vec![], + name: GTIdentifier::new((0, 0).into(), "BookId".into()), + descriptor: GTDescriptor::Branded(GTBranded::Int( + (0, 0).into(), + GTDefinitionId("module".into(), "BookId".into()), + GTIdentifier((0, 0).into(), "BookId".into()) + )) + .into(), + } + .convert(&mut RSConvertContext::empty("module".into())) + .unwrap(), + RSDefinition::Struct(RSStruct { + id: GTDefinitionId("module".into(), "BookId".into()), + doc: None, + attributes: vec![ + "derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)".into() + ], + name: "BookId".into(), + fields: RSStructFields::Tuple(vec![RSDescriptor::Primitive(RSPrimitive::Int),]) + .into(), + }), + ); + } + #[test] fn test_convert_hoisted() { let mut context = RSConvertContext::empty("module".into());