Skip to content

Commit 3cb47c8

Browse files
derive traits for enums and make valuetype fields public
1 parent f3febd7 commit 3cb47c8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

asttoc/src/cppmm_ast_write_rustsys.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::vector<std::string> convert_params(const std::vector<Param>& params) {
103103
std::vector<std::string> convert_fields(const std::vector<Field>& fields) {
104104
std::vector<std::string> result;
105105
for (const auto& f : fields) {
106-
result.push_back(fmt::format("{}: {}", sanitize_keyword(f.name),
106+
result.push_back(fmt::format("pub {}: {}", sanitize_keyword(f.name),
107107
convert_type(f.type)));
108108
}
109109
return result;
@@ -172,8 +172,9 @@ void write_enum(fmt::ostream& out, const NodeEnum* node_enum) {
172172
repr = "u32";
173173
}
174174

175-
out.print("#[repr(transparent)]\npub struct {}(pub {});\n", node_enum->name,
176-
repr);
175+
out.print("#[repr(transparent)]\n#[derive(Debug, Copy, Clone)]\npub struct "
176+
"{}(pub {});\n",
177+
node_enum->name, repr);
177178
for (const auto& p : node_enum->variants) {
178179
out.print("pub const {0}: {1} = {1}({2});\n", p.first, node_enum->name,
179180
p.second);

0 commit comments

Comments
 (0)