Skip to content

Commit

Permalink
Allowed non_camel_case_types on enums
Browse files Browse the repository at this point in the history
Added this macro because enums which contain non-pascalized cases due to
2a97fcd would trigger a clippy lint.
  • Loading branch information
lkirkwood committed Apr 20, 2024
1 parent 93d699c commit ca1cac5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions xsd-parser/src/generator/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,24 @@ pub trait EnumGenerator {
}

fn macros(&self, entity: &Enum, gen: &Generator) -> Cow<'static, str> {
let allows = "#[allow(non_camel_case_types)]\n";

if entity.source == EnumSource::Union {
return "#[derive(PartialEq, Debug, UtilsUnionSerDe)]\n".into();
return format!("{allows}#[derive(PartialEq, Debug, UtilsUnionSerDe)]").into();
}

let derives = "#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]\n";
let tns = gen.target_ns.borrow();
match tns.as_ref() {
Some(tn) => match tn.name() {
Some(name) => format!(
"{derives}#[yaserde(prefix = \"{prefix}\", namespace = \"{prefix}: {uri}\")]\n",
"{allows}{derives}#[yaserde(prefix = \"{prefix}\", namespace = \"{prefix}: {uri}\")]\n",
derives = derives,
prefix = name,
uri = tn.uri()
),
None => format!(
"{derives}#[yaserde(namespace = \"{uri}\")]\n",
"{allows}{derives}#[yaserde(namespace = \"{uri}\")]\n",
derives = derives,
uri = tn.uri()
),
Expand Down

0 comments on commit ca1cac5

Please sign in to comment.