Skip to content

Commit a68620c

Browse files
committed
Add groups export.
- Formatting fixes, use `sort_by` instead of `sort_unstable_by` (as the already created comment states).
1 parent eb574e9 commit a68620c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

godot-macros/src/class/data_models/fields.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
7+
78
use crate::class::Field;
89
use crate::util::bail;
910
use crate::ParseResult;

godot-macros/src/class/data_models/group_export.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub(crate) struct ExportGroupOrdering {
6060

6161
impl ExportGroupOrdering {
6262
/// Creates root which holds all the groups&subgroups.
63+
/// Should be called only once in a given context.
6364
fn root() -> Self {
6465
Self {
6566
identifier: None,
@@ -96,7 +97,7 @@ enum OrderingStage {
9697
SubGroup,
9798
}
9899

99-
// It is recursive but max recursion depth is 1 so it's fine.
100+
// It is recursive but max recursion depth is 2 (root -> group -> subgroup) so it's fine.
100101
fn compare_by_group_and_declaration_order(
101102
field_a: &FieldGroup,
102103
field_b: &FieldGroup,
@@ -172,7 +173,7 @@ pub(crate) fn sort_fields_by_group(fields: &mut Fields) {
172173

173174
// `sort_by` instead of `sort_unstable_by` to preserve original order of declaration.
174175
// Which is not guaranteed by the way albeit worked reliably so far.
175-
fields.all_fields.sort_unstable_by(|a, b| {
176+
fields.all_fields.sort_by(|a, b| {
176177
let (group_a, group_b) = match (&a.group, &b.group) {
177178
(Some(a), Some(b)) => (a, b),
178179
(Some(_), None) => return Ordering::Greater,

0 commit comments

Comments
 (0)