@@ -57,23 +57,23 @@ pub struct StatefulClass<T: Send + 'static> {
5757}
5858
5959impl StatefulClass < ( ) > {
60- pub fn new ( class_name : impl ToString ) -> Self {
60+ pub fn new ( class_name : impl Into < String > ) -> Self {
6161 Self :: new_with_state_constructor ( class_name, || ( ) )
6262 }
6363}
6464
6565impl < 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 {
6767 Self :: new_with_state_constructor ( class_name, Default :: default)
6868 }
6969}
7070
7171impl < T : Send + ' static > StatefulClass < T > {
7272 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 ,
7474 ) -> Self {
7575 Self {
76- class_name : class_name. to_string ( ) ,
76+ class_name : class_name. into ( ) ,
7777 state_constructor : Arc :: new ( state_constructor) ,
7878 method_entities : Vec :: new ( ) ,
7979 property_entities : Vec :: new ( ) ,
@@ -86,7 +86,7 @@ impl<T: Send + 'static> StatefulClass<T> {
8686 }
8787
8888 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 > ,
9090 ) where
9191 F : Fn ( & mut StatefulObj < T > , & mut [ ZVal ] ) -> R + Send + Sync + ' static ,
9292 R : Into < ZVal > + ' static ,
@@ -101,7 +101,7 @@ impl<T: Send + 'static> StatefulClass<T> {
101101 }
102102
103103 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 > ,
105105 ) where
106106 F : Fn ( & mut [ ZVal ] ) -> R + Send + Sync + ' static ,
107107 R : Into < ZVal > + ' static ,
@@ -121,14 +121,14 @@ impl<T: Send + 'static> StatefulClass<T> {
121121 /// receive only scalar zval , otherwise will report fatal error:
122122 /// "Internal zvals cannot be refcounted".
123123 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 > ,
125125 ) {
126126 self . property_entities
127127 . push ( PropertyEntity :: new ( name, visibility, value) ) ;
128128 }
129129
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 ( ) ;
132132 self . parent = Some ( name) ;
133133 }
134134}
@@ -351,9 +351,9 @@ pub struct PropertyEntity {
351351}
352352
353353impl 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 {
355355 Self {
356- name : name. to_string ( ) ,
356+ name : name. into ( ) ,
357357 visibility,
358358 value : value. into ( ) ,
359359 }
0 commit comments