fix(codegen): fix raw repr enums when there is no description

This commit is contained in:
pyrite 2025-09-10 15:25:01 +02:00
parent f15c44adb6
commit 96f57d753a
Signed by: pyrite
GPG key ID: 7F1BA9170CD35D15
2 changed files with 3 additions and 3 deletions

View file

@ -1,7 +1,7 @@
[package] [package]
name = "torn-api-codegen" name = "torn-api-codegen"
authors = ["Pyrit [2111649]"] authors = ["Pyrit [2111649]"]
version = "0.7.3" version = "0.7.4"
edition = "2021" edition = "2021"
description = "Contains the v2 torn API model descriptions and codegen for the bindings" description = "Contains the v2 torn API model descriptions and codegen for the bindings"
license = { workspace = true } license = { workspace = true }

View file

@ -444,7 +444,7 @@ impl Enum {
if shared.len() >= 2 { if shared.len() >= 2 {
for (idx, variant) in shared.into_iter().enumerate() { for (idx, variant) in shared.into_iter().enumerate() {
let label = idx + 1; let label = idx + 1;
variant.name = format!("Variant{}", label); variant.name = format!("Variant{label}");
if let EnumVariantValue::Tuple(values) = &mut variant.value { if let EnumVariantValue::Tuple(values) = &mut variant.value {
if let [EnumVariantTupleValue::Enum { name, inner, .. }] = values.as_mut_slice() if let [EnumVariantTupleValue::Enum { name, inner, .. }] = values.as_mut_slice()
{ {
@ -475,7 +475,6 @@ impl Enum {
let name = format_ident!("{}", self.name); let name = format_ident!("{}", self.name);
let desc = self.description.as_ref().map(|d| { let desc = self.description.as_ref().map(|d| {
quote! { quote! {
#repr
#[doc = #d] #[doc = #d]
} }
}); });
@ -540,6 +539,7 @@ impl Enum {
#[derive(Debug, Clone, PartialEq, #(#derives),*)] #[derive(Debug, Clone, PartialEq, #(#derives),*)]
#[cfg_attr(feature = "strum", derive(strum::EnumIs, strum::EnumTryAs))] #[cfg_attr(feature = "strum", derive(strum::EnumIs, strum::EnumTryAs))]
#serde_attr #serde_attr
#repr
pub enum #name { pub enum #name {
#(#variants),* #(#variants),*
} }