Skip to content

Commit 3781254

Browse files
committed
Add support for assoc items
- post-CR formatting fixes - extend tests
1 parent d9eaeea commit 3781254

File tree

2 files changed

+277
-25
lines changed

2 files changed

+277
-25
lines changed

godot-macros/src/class/godot_dyn.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,24 @@ pub fn attribute_godot_dyn(input_decl: venial::Item) -> ParseResult<TokenStream>
4444
associated_types.push(quote! { #type_name = #type_expr })
4545
}
4646

47-
let associated_impl = if associated_types.is_empty() {
48-
None
47+
let assoc_type_constraints = if associated_types.is_empty() {
48+
TokenStream::new()
4949
} else {
50-
Some(quote! { <#(#associated_types, )*>})
50+
quote! { < #(#associated_types),* > }
5151
};
5252

5353
let class_path = &decl.self_ty;
5454
let prv = quote! { ::godot::private };
5555

56-
//let dynify_fn = format_ident!("__dynify_{}", class_name);
57-
5856
let new_code = quote! {
5957
#decl
6058

61-
impl ::godot::obj::AsDyn<dyn #trait_path #associated_impl> for #class_path {
62-
fn dyn_upcast(&self) -> &(dyn #trait_path #associated_impl + 'static) {
59+
impl ::godot::obj::AsDyn<dyn #trait_path #assoc_type_constraints> for #class_path {
60+
fn dyn_upcast(&self) -> &(dyn #trait_path #assoc_type_constraints + 'static) {
6361
self
6462
}
6563

66-
fn dyn_upcast_mut(&mut self) -> &mut (dyn #trait_path #associated_impl + 'static) {
64+
fn dyn_upcast_mut(&mut self) -> &mut (dyn #trait_path #assoc_type_constraints + 'static) {
6765
self
6866
}
6967
}

0 commit comments

Comments
 (0)