Skip to content

Commit

Permalink
fix: issue introduced in d50dbfd
Browse files Browse the repository at this point in the history
The order in which enum fields must are inserted in structs must be preserved. The ' HashSet` type doesn't preserve the order, but `IndexSet` does it.
  • Loading branch information
plusvic committed Feb 26, 2024
1 parent 7695c7f commit d5a0924
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/src/types/structure.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::collections::HashSet;
use std::iter;
use std::ops::Deref;
use std::rc::Rc;

use bstr::BString;
use indexmap::IndexMap;
use indexmap::{IndexMap, IndexSet};
use protobuf::reflect::{
EnumDescriptor, FieldDescriptor, MessageDescriptor, ReflectMapRef,
ReflectRepeatedRef, ReflectValueRef, RuntimeFieldType, RuntimeType,
Expand Down Expand Up @@ -300,7 +299,7 @@ impl Struct {
fields.sort_by(|a, b| a.1.number.cmp(&b.1.number));

if generate_fields_for_enums {
let mut enums = HashSet::new();
let mut enums = IndexSet::new();

// Enums declared inside a message are treated as a nested
// structure where each field is an enum item, and each
Expand Down

0 comments on commit d5a0924

Please sign in to comment.