File tree 6 files changed +21
-16
lines changed
6 files changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,13 @@ use std::{
4
4
marker:: PhantomData ,
5
5
} ;
6
6
7
- trait Newish {
7
+ pub trait Newish {
8
8
fn new ( ) -> Self ;
9
9
}
10
10
11
11
#[ fxstruct( builder, into) ]
12
12
#[ derive( Debug ) ]
13
- struct Plain < ' a , ' b , T >
13
+ pub struct Plain < ' a , ' b , T >
14
14
where
15
15
T : Display + Debug + Default + Newish ,
16
16
' b : ' a ,
Original file line number Diff line number Diff line change @@ -305,16 +305,6 @@ impl FXRewriter {
305
305
}
306
306
}
307
307
308
- fn builder_struct_visibility ( & self ) -> TokenStream {
309
- let ctx = self . ctx ( ) ;
310
- self . ctx ( )
311
- . args ( )
312
- . get_helper ( FXHelperKind :: Builder )
313
- . and_then ( |builder| builder. public_mode ( ) . map ( |pm| pm. to_token_stream ( ) ) )
314
- . or_else ( || Some ( ctx. input ( ) . vis ( ) . to_token_stream ( ) ) )
315
- . unwrap ( )
316
- }
317
-
318
308
fn builder_field_ctxs ( & self ) -> Vec < darling:: Result < Ref < FXFieldCtx > > > {
319
309
let ctx = self . ctx ( ) ;
320
310
let builder_field_idents = ctx. builder_field_ident ( ) . borrow ( ) ;
@@ -326,7 +316,7 @@ impl FXRewriter {
326
316
327
317
fn builder_impl ( & self ) -> TokenStream {
328
318
let ctx = self . ctx ( ) ;
329
- let vis = self . builder_struct_visibility ( ) ;
319
+ let vis = ctx . builder_struct_visibility ( ) ;
330
320
let builder_ident = ctx. builder_ident ( ) ;
331
321
let builders = ctx. builders_combined ( ) ;
332
322
let input_ident = ctx. input_ident ( ) ;
@@ -432,7 +422,7 @@ impl FXRewriter {
432
422
let generics = ctx. input ( ) . generics ( ) ;
433
423
let where_clause = & generics. where_clause ;
434
424
let span = ctx. helper_span ( FXHelperKind :: Builder ) ;
435
- let vis = self . builder_struct_visibility ( ) ;
425
+ let vis = ctx . builder_struct_visibility ( ) ;
436
426
let attributes = args. builder_attributes ( ) ;
437
427
let builder_ident = ctx. builder_ident ( ) ;
438
428
Original file line number Diff line number Diff line change @@ -358,6 +358,7 @@ pub trait FXCodeGenContextual {
358
358
if fctx. forced_builder ( ) || fctx. needs_builder ( ) {
359
359
let ident = fctx. ident_tok ( ) ;
360
360
let mut builder_name = self . helper_name ( fctx, FXHelperKind :: Builder ) ?;
361
+ let vis = fctx. builder_method_visibility ( ) ;
361
362
// .builder_name(fctx)?;
362
363
// .unwrap_or(format_ident!("{}", fctx.helper_base_name().expect("Field name")).to_token_stream());
363
364
let span = fctx. helper_span ( FXHelperKind :: Builder ) ;
@@ -366,7 +367,7 @@ pub trait FXCodeGenContextual {
366
367
builder_name. set_span ( span) ;
367
368
Ok ( quote_spanned ! [ span=>
368
369
#attributes
369
- pub fn #builder_name #gen_params( mut self , value: #val_type) -> Self {
370
+ #vis fn #builder_name #gen_params( mut self , value: #val_type) -> Self {
370
371
self . #ident = :: std:: option:: Option :: Some ( value #into_tok) ;
371
372
self
372
373
}
Original file line number Diff line number Diff line change @@ -450,6 +450,14 @@ impl FXCodeGenCtx {
450
450
} )
451
451
}
452
452
453
+ pub fn builder_struct_visibility ( & self ) -> TokenStream {
454
+ self . args ( )
455
+ . get_helper ( FXHelperKind :: Builder )
456
+ . and_then ( |builder| builder. public_mode ( ) . map ( |pm| pm. to_token_stream ( ) ) )
457
+ . or_else ( || Some ( self . input ( ) . vis ( ) . to_token_stream ( ) ) )
458
+ . unwrap ( )
459
+ }
460
+
453
461
#[ inline( always) ]
454
462
pub fn builder_has_post_build ( & self ) -> bool {
455
463
self . args . builder ( ) . as_ref ( ) . map_or ( false , |b| b. has_post_build ( ) )
Original file line number Diff line number Diff line change @@ -429,6 +429,13 @@ impl FXFieldCtx {
429
429
self . attrs ( ) . iter ( ) . cloned ( ) . collect ( )
430
430
}
431
431
432
+ pub fn builder_method_visibility ( & self ) -> TokenStream {
433
+ self . builder ( ) . as_ref ( ) . and_then ( |b| b. public_mode ( ) ) . map_or_else (
434
+ || self . codegen_ctx ( ) . builder_struct_visibility ( ) ,
435
+ |pub_mode| pub_mode. to_token_stream ( ) ,
436
+ )
437
+ }
438
+
432
439
pub fn set_builder_checker ( & self , bc : TokenStream ) {
433
440
* self . builder_checker . borrow_mut ( ) = Some ( bc) ;
434
441
}
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ fn <scope> ask_user
8
8
return ${reply}
9
9
end
10
10
11
-
12
11
# Function to generate the power set of an array
13
12
fn <scope> generate_power_set
14
13
input = set ${1}
You can’t perform that action at this time.
0 commit comments