Skip to content

Commit a048fc4

Browse files
committed
Properties are now registered in order of declaration
1 parent 4c5184c commit a048fc4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

gdnative-derive/src/native_script.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use proc_macro::TokenStream;
22
use proc_macro2::TokenStream as TokenStream2;
33

4-
use std::collections::HashMap;
54
use syn::spanned::Spanned;
65
use syn::{Data, DeriveInput, Fields, Ident, Meta, MetaList, NestedMeta, Path, Stmt, Type};
76

@@ -13,7 +12,7 @@ pub(crate) struct DeriveData {
1312
pub(crate) base: Type,
1413
pub(crate) register_callback: Option<Path>,
1514
pub(crate) user_data: Type,
16-
pub(crate) properties: HashMap<Ident, PropertyAttrArgs>,
15+
pub(crate) properties: Vec<(Ident, PropertyAttrArgs)>,
1716
pub(crate) no_constructor: bool,
1817
}
1918

@@ -188,7 +187,7 @@ fn parse_derive_input(input: &DeriveInput) -> Result<DeriveData, syn::Error> {
188187
};
189188

190189
// Find all fields with a `#[property]` attribute
191-
let mut properties = HashMap::new();
190+
let mut properties = Vec::new();
192191

193192
if let Fields::Named(names) = &struct_data.fields {
194193
for field in &names.named {
@@ -232,7 +231,7 @@ fn parse_derive_input(input: &DeriveInput) -> Result<DeriveData, syn::Error> {
232231
.ident
233232
.clone()
234233
.ok_or_else(|| syn::Error::new(field.ident.span(), "Fields should be named"))?;
235-
properties.insert(ident, builder.done());
234+
properties.push((ident, builder.done()));
236235
}
237236
}
238237
};

0 commit comments

Comments
 (0)