@@ -57,23 +57,23 @@ pub struct StatefulClass<T: Send + 'static> {
57
57
}
58
58
59
59
impl StatefulClass < ( ) > {
60
- pub fn new ( class_name : impl ToString ) -> Self {
60
+ pub fn new ( class_name : impl Into < String > ) -> Self {
61
61
Self :: new_with_state_constructor ( class_name, || ( ) )
62
62
}
63
63
}
64
64
65
65
impl < T : Default + Send + ' static > StatefulClass < T > {
66
- pub fn new_with_default_state ( class_name : impl ToString ) -> Self {
66
+ pub fn new_with_default_state ( class_name : impl Into < String > ) -> Self {
67
67
Self :: new_with_state_constructor ( class_name, Default :: default)
68
68
}
69
69
}
70
70
71
71
impl < T : Send + ' static > StatefulClass < T > {
72
72
pub fn new_with_state_constructor (
73
- class_name : impl ToString , state_constructor : impl Fn ( ) -> T + Send + Sync + ' static ,
73
+ class_name : impl Into < String > , state_constructor : impl Fn ( ) -> T + Send + Sync + ' static ,
74
74
) -> Self {
75
75
Self {
76
- class_name : class_name. to_string ( ) ,
76
+ class_name : class_name. into ( ) ,
77
77
state_constructor : Arc :: new ( state_constructor) ,
78
78
method_entities : Vec :: new ( ) ,
79
79
property_entities : Vec :: new ( ) ,
@@ -86,7 +86,7 @@ impl<T: Send + 'static> StatefulClass<T> {
86
86
}
87
87
88
88
pub fn add_method < F , R > (
89
- & mut self , name : impl ToString , vis : Visibility , handler : F , arguments : Vec < Argument > ,
89
+ & mut self , name : impl Into < String > , vis : Visibility , handler : F , arguments : Vec < Argument > ,
90
90
) where
91
91
F : Fn ( & mut StatefulObj < T > , & mut [ ZVal ] ) -> R + Send + Sync + ' static ,
92
92
R : Into < ZVal > + ' static ,
@@ -101,7 +101,7 @@ impl<T: Send + 'static> StatefulClass<T> {
101
101
}
102
102
103
103
pub fn add_static_method < F , R > (
104
- & mut self , name : impl ToString , vis : Visibility , handler : F , arguments : Vec < Argument > ,
104
+ & mut self , name : impl Into < String > , vis : Visibility , handler : F , arguments : Vec < Argument > ,
105
105
) where
106
106
F : Fn ( & mut [ ZVal ] ) -> R + Send + Sync + ' static ,
107
107
R : Into < ZVal > + ' static ,
@@ -121,14 +121,14 @@ impl<T: Send + 'static> StatefulClass<T> {
121
121
/// receive only scalar zval , otherwise will report fatal error:
122
122
/// "Internal zvals cannot be refcounted".
123
123
pub fn add_property (
124
- & mut self , name : impl ToString , visibility : Visibility , value : impl Into < Scalar > ,
124
+ & mut self , name : impl Into < String > , visibility : Visibility , value : impl Into < Scalar > ,
125
125
) {
126
126
self . property_entities
127
127
. push ( PropertyEntity :: new ( name, visibility, value) ) ;
128
128
}
129
129
130
- pub fn extends ( & mut self , name : impl ToString ) {
131
- let name = name. to_string ( ) ;
130
+ pub fn extends ( & mut self , name : impl Into < String > ) {
131
+ let name = name. into ( ) ;
132
132
self . parent = Some ( name) ;
133
133
}
134
134
}
@@ -351,9 +351,9 @@ pub struct PropertyEntity {
351
351
}
352
352
353
353
impl PropertyEntity {
354
- pub fn new ( name : impl ToString , visibility : Visibility , value : impl Into < Scalar > ) -> Self {
354
+ pub fn new ( name : impl Into < String > , visibility : Visibility , value : impl Into < Scalar > ) -> Self {
355
355
Self {
356
- name : name. to_string ( ) ,
356
+ name : name. into ( ) ,
357
357
visibility,
358
358
value : value. into ( ) ,
359
359
}
0 commit comments