File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,7 @@ fn expand_property_fn(props: &[PropDesc]) -> TokenStream2 {
312
312
field_ident,
313
313
member,
314
314
get,
315
+ ty,
315
316
..
316
317
} = p;
317
318
@@ -320,7 +321,10 @@ fn expand_property_fn(props: &[PropDesc]) -> TokenStream2 {
320
321
get. as_ref ( ) . map ( |get| {
321
322
let body = match ( member, get) {
322
323
( _, MaybeCustomFn :: Custom ( expr) ) => quote ! (
323
- DerivedPropertiesEnum :: #enum_ident => :: std:: convert:: From :: from( ( #expr) ( & self ) )
324
+ DerivedPropertiesEnum :: #enum_ident => {
325
+ let value: <#ty as #crate_ident:: Property >:: Value = ( #expr) ( & self ) ;
326
+ :: std:: convert:: From :: from( value)
327
+ }
324
328
) ,
325
329
( None , MaybeCustomFn :: Default ) => quote ! (
326
330
DerivedPropertiesEnum :: #enum_ident =>
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ fn props() {
45
45
bar : Mutex < String > ,
46
46
#[ property( get, set) ]
47
47
double : RefCell < f64 > ,
48
+ #[ property( get = |_| 42.0 , set) ]
49
+ infer_inline_type : RefCell < f64 > ,
48
50
// The following property doesn't store any data. The value of the property is calculated
49
51
// when the value is accessed.
50
52
#[ property( get = Self :: hello_world) ]
@@ -231,6 +233,9 @@ fn props() {
231
233
myfoo. set_double ( 0.1 ) ;
232
234
assert_eq ! ( myfoo. property:: <f64 >( "double" ) , 0.1 ) ;
233
235
236
+ myfoo. set_infer_inline_type ( 42.0 ) ;
237
+ assert_eq ! ( myfoo. property:: <f64 >( "infer-inline-type" ) , 42.0 ) ;
238
+
234
239
// simple with various String types
235
240
myfoo. set_bar ( String :: from ( "setter working" ) ) ;
236
241
myfoo. set_bar ( glib:: GString :: from ( "setter working" ) ) ;
You can’t perform that action at this time.
0 commit comments