Skip to content

Commit

Permalink
Fix for fixed value enum variants without preserve-encodings (#207)
Browse files Browse the repository at this point in the history
* Fix for fixed value enum variants without preserve-encodings

* cargo fmt
  • Loading branch information
rooooooooob authored Aug 1, 2023
1 parent 0469793 commit 3f1c296
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6275,14 +6275,16 @@ fn generate_enum(
} else {
variant.name_as_var()
};
let (before, after) =
if cli.preserve_encodings || !variant.rust_type().is_fixed_value() {
(Cow::from(format!("let {var_names_str} = ")), ";")
} else {
(Cow::from(""), "")
};
let mut variant_deser_code = gen_scope.generate_deserialize(
types,
(variant.rust_type()).into(),
DeserializeBeforeAfter::new(
&format!("let {var_names_str} = "),
";",
false,
),
DeserializeBeforeAfter::new(&before, after, false),
DeserializeConfig::new(&variant.name_as_var()),
cli,
);
Expand Down

0 comments on commit 3f1c296

Please sign in to comment.