Fixed enum serializing

This commit is contained in:
Cerber Ursi
2021-11-27 19:09:12 +07:00
parent 89cf720cd4
commit 3327951f1f
3 changed files with 47 additions and 10 deletions
+4 -3
View File
@@ -9,7 +9,8 @@ use toml::from_str;
#[derive(Deserialize, Default)]
struct Data {
types: String,
main_type: String,
support_types: Option<String>,
definition: String,
value: String,
}
@@ -38,8 +39,8 @@ impl Data {
write!(
File::create(&path.with_file_name(format!("{}-user.rs", name))).unwrap(),
include_str!("user.tpl"),
types = self.types,
ser_type = self.types.split(",").next().unwrap(),
types = self.support_types.as_ref().map_or(self.main_type.clone(), |types| format!("{},{}", self.main_type, types)),
ser_type = self.main_type,
value = self.value
).unwrap();
write!(