@@ -120,7 +120,7 @@ struct ParsedImpl<'a> {
120120 change_method_case : RenameRule ,
121121 change_constant_case : RenameRule ,
122122 functions : Vec < FnBuilder > ,
123- constructor : Option < Function < ' a > > ,
123+ constructor : Option < ( Function < ' a > , Option < Visibility > ) > ,
124124 constants : Vec < Constant < ' a > > ,
125125}
126126
@@ -212,7 +212,7 @@ impl<'a> ParsedImpl<'a> {
212212 let mut modifiers: HashSet < MethodModifier > = HashSet :: new ( ) ;
213213
214214 if matches ! ( opts. ty, MethodTy :: Constructor ) {
215- if self . constructor . replace ( func) . is_some ( ) {
215+ if self . constructor . replace ( ( func, opts . vis . into ( ) ) ) . is_some ( ) {
216216 bail ! ( method => "Only one constructor can be provided per class." ) ;
217217 }
218218 } else {
@@ -264,7 +264,7 @@ impl<'a> ParsedImpl<'a> {
264264 let constructor = self
265265 . constructor
266266 . as_ref ( )
267- . map ( |func| func. constructor_meta ( self . path ) )
267+ . map ( |( func, vis ) | func. constructor_meta ( self . path , vis . as_ref ( ) ) )
268268 . option_tokens ( ) ;
269269 let constants = self . constants . iter ( ) . map ( |c| {
270270 let name = & c. name ;
@@ -306,11 +306,8 @@ impl quote::ToTokens for FnBuilder {
306306 let builder = & self . builder ;
307307 // TODO(cole_d): allow more flags via attributes
308308 let mut flags = vec ! [ ] ;
309- flags. push ( match self . vis {
310- Visibility :: Public => quote ! { :: ext_php_rs:: flags:: MethodFlags :: Public } ,
311- Visibility :: Protected => quote ! { :: ext_php_rs:: flags:: MethodFlags :: Protected } ,
312- Visibility :: Private => quote ! { :: ext_php_rs:: flags:: MethodFlags :: Private } ,
313- } ) ;
309+ let vis = & self . vis ;
310+ flags. push ( quote ! { #vis } ) ;
314311 for flag in & self . modifiers {
315312 flags. push ( quote ! { #flag } ) ;
316313 }
0 commit comments