File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-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. to_value( ) ) ) ;
501
+ let body = quote ! ( self . set_property_from_value( #name, & value. as_ref ( ) . to_value( ) ) ) ;
502
502
let fn_prototype = {
503
503
let ident = format_ident ! ( "set_{}" , ident) ;
504
- quote ! ( pub fn #ident( & self , value: & << #ty as #crate_ident:: Property >:: Value as #crate_ident:: HasParamSpec >:: SetValue ) )
504
+ quote ! ( pub fn #ident< ' a> ( & self , value: impl AsRef <<< #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 @@ -78,6 +78,8 @@ fn props() {
78
78
boxed : RefCell < SimpleBoxedString > ,
79
79
#[ property( get, set, builder( SimpleEnum :: static_type( ) ) ) ]
80
80
fenum : RefCell < SimpleEnum > ,
81
+ #[ property( get, set, builder( glib:: Object :: static_type( ) ) ) ]
82
+ object : RefCell < Option < glib:: Object > > ,
81
83
#[ property( get, set) ]
82
84
optional : RefCell < Option < String > > ,
83
85
#[ property( get, set) ]
@@ -231,6 +233,17 @@ fn props() {
231
233
"setter working" . to_string( )
232
234
) ;
233
235
236
+ // simple with various String types
237
+ myfoo. set_bar ( String :: from ( "setter working" ) ) ;
238
+ myfoo. set_bar ( glib:: GString :: from ( "setter working" ) ) ;
239
+ assert_eq ! (
240
+ myfoo. property:: <String >( "bar" ) ,
241
+ "setter working" . to_string( )
242
+ ) ;
243
+
244
+ // object subclass
245
+ myfoo. set_object ( glib:: BoxedAnyObject :: new ( "" ) ) ;
246
+
234
247
// custom
235
248
myfoo. set_fake_field ( "fake setter" ) ;
236
249
assert_eq ! (
You can’t perform that action at this time.
0 commit comments