File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -498,10 +498,10 @@ fn expand_getset_properties_impl(props: &[PropDesc]) -> TokenStream2 {
498
498
quote ! ( #fn_prototype { #body } )
499
499
} ) ;
500
500
let setter = ( p. set . is_some ( ) && !p. flags . contains ( & "construct_only" ) ) . then ( || {
501
- let body = quote ! ( self . set_property_from_value( #name, & value . as_ref ( ) . to_value( ) ) ) ;
501
+ let body = quote ! ( self . set_property_from_value( #name, & std :: borrow :: Borrow :: borrow ( & value ) . to_value( ) ) ) ;
502
502
let fn_prototype = {
503
503
let ident = format_ident ! ( "set_{}" , ident) ;
504
- quote ! ( pub fn #ident<' a>( & self , value: impl AsRef <<<#ty as #crate_ident:: Property >:: Value as #crate_ident:: HasParamSpec >:: SetValue >) )
504
+ quote ! ( pub fn #ident<' a>( & self , value: impl std :: borrow :: Borrow <<<#ty as #crate_ident:: Property >:: Value as #crate_ident:: HasParamSpec >:: SetValue >) )
505
505
} ;
506
506
quote ! ( #fn_prototype { #body } )
507
507
} ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ fn props() {
48
48
pub struct Foo {
49
49
#[ property( get, set) ]
50
50
bar : Mutex < String > ,
51
+ #[ property( get, set) ]
52
+ double : RefCell < f64 > ,
51
53
// The following property doesn't store any data. The value of the property is calculated
52
54
// when the value is accessed.
53
55
#[ property( get = Self :: hello_world) ]
@@ -233,6 +235,9 @@ fn props() {
233
235
"setter working" . to_string( )
234
236
) ;
235
237
238
+ myfoo. set_double ( 0.1 ) ;
239
+ assert_eq ! ( myfoo. property:: <f64 >( "double" ) , 0.1 ) ;
240
+
236
241
// simple with various String types
237
242
myfoo. set_bar ( String :: from ( "setter working" ) ) ;
238
243
myfoo. set_bar ( glib:: GString :: from ( "setter working" ) ) ;
You can’t perform that action at this time.
0 commit comments