@@ -120,7 +120,7 @@ struct ParsedImpl<'a> {
120
120
change_method_case : RenameRule ,
121
121
change_constant_case : RenameRule ,
122
122
functions : Vec < FnBuilder > ,
123
- constructor : Option < Function < ' a > > ,
123
+ constructor : Option < ( Function < ' a > , Option < Visibility > ) > ,
124
124
constants : Vec < Constant < ' a > > ,
125
125
}
126
126
@@ -212,7 +212,7 @@ impl<'a> ParsedImpl<'a> {
212
212
let mut modifiers: HashSet < MethodModifier > = HashSet :: new ( ) ;
213
213
214
214
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 ( ) {
216
216
bail ! ( method => "Only one constructor can be provided per class." ) ;
217
217
}
218
218
} else {
@@ -264,7 +264,7 @@ impl<'a> ParsedImpl<'a> {
264
264
let constructor = self
265
265
. constructor
266
266
. as_ref ( )
267
- . map ( |func| func. constructor_meta ( self . path ) )
267
+ . map ( |( func, vis ) | func. constructor_meta ( self . path , vis . as_ref ( ) ) )
268
268
. option_tokens ( ) ;
269
269
let constants = self . constants . iter ( ) . map ( |c| {
270
270
let name = & c. name ;
@@ -306,11 +306,8 @@ impl quote::ToTokens for FnBuilder {
306
306
let builder = & self . builder ;
307
307
// TODO(cole_d): allow more flags via attributes
308
308
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 } ) ;
314
311
for flag in & self . modifiers {
315
312
flags. push ( quote ! { #flag } ) ;
316
313
}
0 commit comments