@@ -160,18 +160,13 @@ impl JsComponentInstance {
160
160
}
161
161
} ;
162
162
163
- if let Some ( return_type) = & return_type {
164
- if let Ok ( value) = super :: to_value ( & env, result, return_type) {
165
- return value;
166
- } else {
167
- eprintln ! (
168
- "Node.js: cannot convert return type of callback {}" ,
169
- callback_name
170
- ) ;
171
- return slint_interpreter:: default_value_for_type ( return_type) ;
172
- }
173
- } else {
163
+ if matches ! ( return_type, Type :: Void ) {
174
164
Value :: Void
165
+ } else if let Ok ( value) = super :: to_value ( & env, result, & return_type) {
166
+ return value;
167
+ } else {
168
+ eprintln ! ( "Node.js: cannot convert return type of callback {callback_name}" ) ;
169
+ return slint_interpreter:: default_value_for_type ( & return_type) ;
175
170
}
176
171
}
177
172
} )
@@ -237,18 +232,13 @@ impl JsComponentInstance {
237
232
}
238
233
} ;
239
234
240
- if let Some ( return_type) = & return_type {
241
- if let Ok ( value) = super :: to_value ( & env, result, return_type) {
242
- return value;
243
- } else {
244
- eprintln ! (
245
- "Node.js: cannot convert return type of callback {}" ,
246
- callback_name
247
- ) ;
248
- return slint_interpreter:: default_value_for_type ( return_type) ;
249
- }
250
- } else {
235
+ if matches ! ( return_type, Type :: Void ) {
251
236
Value :: Void
237
+ } else if let Ok ( value) = super :: to_value ( & env, result, & return_type) {
238
+ return value;
239
+ } else {
240
+ eprintln ! ( "Node.js: cannot convert return type of callback {callback_name}" ) ;
241
+ return slint_interpreter:: default_value_for_type ( & return_type) ;
252
242
}
253
243
}
254
244
} )
@@ -306,10 +296,7 @@ impl JsComponentInstance {
306
296
} ) ?;
307
297
308
298
let args = match ty {
309
- Type :: Callback ( callback) => {
310
- Self :: invoke_args ( env, & callback_name, arguments, & callback. args ) ?
311
- }
312
- Type :: Function ( function) => {
299
+ Type :: Callback ( function) | Type :: Function ( function) => {
313
300
Self :: invoke_args ( env, & callback_name, arguments, & function. args ) ?
314
301
}
315
302
_ => {
@@ -352,10 +339,7 @@ impl JsComponentInstance {
352
339
} ) ?;
353
340
354
341
let args = match ty {
355
- Type :: Callback ( callback) => {
356
- Self :: invoke_args ( env, & callback_name, arguments, & callback. args ) ?
357
- }
358
- Type :: Function ( function) => {
342
+ Type :: Callback ( function) | Type :: Function ( function) => {
359
343
Self :: invoke_args ( env, & callback_name, arguments, & function. args ) ?
360
344
}
361
345
_ => {
0 commit comments