@@ -29,8 +29,8 @@ pub struct ClassBuilder<'a> {
2929 extends : * mut ClassEntry ,
3030 methods : Vec < FunctionEntry > ,
3131 object_override : Option < unsafe extern "C" fn ( class_type : * mut ClassEntry ) -> * mut ZendObject > ,
32- properties : Vec < ( & ' a str , Zval , PropertyFlags ) > ,
33- constants : Vec < ( & ' a str , Zval ) > ,
32+ properties : Vec < ( String , Zval , PropertyFlags ) > ,
33+ constants : Vec < ( String , Zval ) > ,
3434}
3535
3636impl < ' a > ClassBuilder < ' a > {
@@ -91,11 +91,12 @@ impl<'a> ClassBuilder<'a> {
9191 /// * `name` - The name of the property to add to the class.
9292 /// * `default` - The default value of the property.
9393 /// * `flags` - Flags relating to the property. See [`PropertyFlags`].
94- #[ allow( unused_mut, unused_variables) ]
95- pub fn property < T > ( mut self , name : & ' a str , default : T , flags : PropertyFlags ) -> Self
96- where
97- T : Into < Zval > ,
98- {
94+ pub fn property (
95+ mut self ,
96+ name : impl AsRef < str > ,
97+ default : impl Into < Zval > ,
98+ flags : PropertyFlags ,
99+ ) -> Self {
99100 let mut default = default. into ( ) ;
100101
101102 if default. is_string ( ) {
@@ -104,7 +105,8 @@ impl<'a> ClassBuilder<'a> {
104105 default. set_persistent_string ( val) ;
105106 }
106107
107- self . properties . push ( ( name, default, flags) ) ;
108+ self . properties
109+ . push ( ( name. as_ref ( ) . to_string ( ) , default, flags) ) ;
108110 self
109111 }
110112
@@ -115,10 +117,7 @@ impl<'a> ClassBuilder<'a> {
115117 ///
116118 /// * `name` - The name of the constant to add to the class.
117119 /// * `value` - The value of the constant.
118- pub fn constant < T > ( mut self , name : & ' a str , value : T ) -> Self
119- where
120- T : Into < Zval > ,
121- {
120+ pub fn constant ( mut self , name : impl AsRef < str > , value : impl Into < Zval > ) -> Self {
122121 let mut value = value. into ( ) ;
123122
124123 if value. is_string ( ) {
@@ -127,7 +126,7 @@ impl<'a> ClassBuilder<'a> {
127126 value. set_persistent_string ( val) ;
128127 }
129128
130- self . constants . push ( ( name, value) ) ;
129+ self . constants . push ( ( name. as_ref ( ) . to_string ( ) , value) ) ;
131130 self
132131 }
133132
@@ -175,7 +174,7 @@ impl<'a> ClassBuilder<'a> {
175174 unsafe {
176175 zend_declare_property (
177176 class,
178- c_str ( name) ,
177+ c_str ( & name) ,
179178 name. len ( ) as _ ,
180179 & mut default,
181180 flags. bits ( ) as _ ,
@@ -185,7 +184,7 @@ impl<'a> ClassBuilder<'a> {
185184
186185 for ( name, value) in self . constants {
187186 let value = Box :: into_raw ( Box :: new ( value) ) ;
188- unsafe { zend_declare_class_constant ( class, c_str ( name) , name. len ( ) as u64 , value) } ;
187+ unsafe { zend_declare_class_constant ( class, c_str ( & name) , name. len ( ) as u64 , value) } ;
189188 }
190189
191190 if let Some ( object_override) = self . object_override {
0 commit comments