Skip to content

Commit bce3b1a

Browse files
committed
Simplify string condition
1 parent 40a5804 commit bce3b1a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎cpp2rust/converter/mapper.cpp‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,10 @@ std::string ToRustName(std::string name) {
739739
}
740740
}
741741

742-
for (std::string_view runtime_name : {"Ptr", "Value"}) {
743-
if (name.starts_with(runtime_name) &&
744-
std::ranges::all_of(std::string_view(name).substr(runtime_name.size()),
745-
[](char c) { return c == '_'; })) {
746-
name += '_';
747-
break;
748-
}
742+
std::string_view stem(name);
743+
stem = stem.substr(0, stem.find_last_not_of('_') + 1);
744+
if (stem == "Ptr" || stem == "Value") {
745+
name += '_';
749746
}
750747
return name;
751748
}

0 commit comments

Comments
 (0)