Skip to content

Commit 5af9158

Browse files
committed
glib-macros: Strip raw identifier prefix from struct members for the Properties macro
This allows structs with members named `r#fn`, `r#loop`, `r#pub`, etc. to derive `glib::Properties`
1 parent e8e8318 commit 5af9158

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

glib-macros/src/properties.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ fn expand_wrapper_notify_prop(props: &[PropDesc]) -> TokenStream2 {
585585
quote!(#(#emit_fns)*)
586586
}
587587

588-
fn name_to_enum_ident(mut name: String) -> syn::Ident {
588+
fn name_to_enum_ident(name: String) -> syn::Ident {
589+
let mut name = name.strip_prefix("r#").unwrap_or(&name).to_owned();
589590
let mut slice = name.as_mut_str();
590591
while let Some(i) = slice.find('-') {
591592
let (head, tail) = slice.split_at_mut(i);
@@ -606,6 +607,7 @@ fn expand_properties_enum(props: &[PropDesc]) -> TokenStream2 {
606607
.iter()
607608
.map(|p| {
608609
let name: String = p.name.value();
610+
609611
name_to_enum_ident(name)
610612
})
611613
.collect();

0 commit comments

Comments
 (0)