File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,9 +40,10 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
4040 ( "Vec<u8>" , "bytes" ) ,
4141 ] ;
4242
43- for item in type_data {
44- let is_union = matches ! ( item , PythonBindType :: Union { .. } ) ;
43+ let mut sorted_types : Vec < & PythonBindType > = type_data . iter ( ) . collect ( ) ;
44+ sorted_types . sort_by ( |a , b| a . struct_name ( ) . cmp ( b . struct_name ( ) ) ) ;
4545
46+ for item in sorted_types {
4647 let type_name = item. struct_name ( ) ;
4748
4849 write_fmt ! ( file, "class {type_name}:" ) ;
@@ -217,7 +218,7 @@ pub fn generator(type_data: &[PythonBindType]) -> io::Result<()> {
217218 write_str ! ( file, " def __repr__(self) -> str: ..." ) ;
218219 write_str ! ( file, " def __hash__(self) -> str: ..." ) ;
219220
220- if !is_union {
221+ if !( matches ! ( item , PythonBindType :: Union { .. } ) ) {
221222 write_str ! ( file, " def pack(self) -> bytes: ..." ) ;
222223 write_str ! ( file, " @staticmethod" ) ;
223224 write_fmt ! ( file, " def unpack(data: bytes) -> {type_name}:" ) ;
You can’t perform that action at this time.
0 commit comments