From 2d0cf5c33b925840a2bac0a9c58262a0a7355523 Mon Sep 17 00:00:00 2001 From: Nils Andre Date: Sun, 17 Nov 2024 11:32:52 +0000 Subject: [PATCH 1/2] customize tag name --- src/bindgen/ir/enumeration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 8927b8be..85ee1d71 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -870,7 +870,7 @@ impl Enum { out.write("enum "); } - write!(out, "{} tag;", tag_name); + write!(out, "{} tag;", tag_name, self.annotations.atom("tag-field-name").map_or(&"tag", |tag_field_name| tag_field_name.expect("tag-field-name"))); if wrap_tag { out.close_brace(true); From 1bebe48258f3b36e46bfe0662eb52f6a3945c2ca Mon Sep 17 00:00:00 2001 From: Nils Andre Date: Sun, 17 Nov 2024 11:47:06 +0000 Subject: [PATCH 2/2] fix code --- src/bindgen/ir/enumeration.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 85ee1d71..566bd0ec 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -870,7 +870,14 @@ impl Enum { out.write("enum "); } - write!(out, "{} tag;", tag_name, self.annotations.atom("tag-field-name").map_or(&"tag", |tag_field_name| tag_field_name.expect("tag-field-name"))); + { + let binding = self.annotations.atom("tag-field-name"); + let tag_field_name = binding + .as_ref() + .map_or("tag", |tag_field_name| tag_field_name.as_ref().unwrap()); + + write!(out, "{} {};", tag_name, tag_field_name); + } if wrap_tag { out.close_brace(true);