Skip to content

Commit

Permalink
enums: fix index parameter as we can get it with ordinal()
Browse files Browse the repository at this point in the history
  • Loading branch information
adjabaev committed Aug 26, 2024
1 parent d778ff2 commit 6d1beb2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions bindings/scripts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ fn create_java_enum(name: &str, values: Vec<&str>) -> String {

let mut result = format!("package {};\n\npublic enum {} {{\n", package, enum_name);

for (index, value) in values.iter().enumerate() {
let java_value = value.to_case(Case::UpperSnake);
for value in values.iter() {
result.push_str(" ");
result.push_str(&java_value);
result.push('(');
result.push_str(&index.to_string());
result.push_str("),\n");
result.push_str(&value.to_case(Case::UpperSnake));
result.push_str(",\n");
}

// eliminate the last comma
Expand Down

0 comments on commit 6d1beb2

Please sign in to comment.