macon 1.3.0

Another builder macro-based generator with its own idioms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
//! Another builder macro-based generator with its own idioms.
//!
//! "[Maçon](https://fr.wiktionary.org/wiki/ma%C3%A7on#Nom_commun_2)" is French translation for "[builder](https://www.wordreference.com/enfr/builder)"
//!
//! ### Usage
//!
//! ```
//! #[macro_use] extern crate macon;
//!
//! #[derive(Builder)]
//! struct MyType {
//!   integer: i32,
//!   string: String,
//!   optional: Option<String>,
//! }
//!
//! let _mytype: MyType = MyType::builder()
//!     .integer(42)
//!     .string("foobar")
//!     .build();
//! ```
//!
//! * adds a builder struct (`<TargetStruct>Builder`)
//! * build struct implements [`Default`]
//! * adds a `builder()` function to target struct to initialize a new builder
//! * each target struct field can be set with function of same name and parameter of same type
//! * use `build()` function to create new target struct instance
//! * any unset field will make `build()` call not compile (default)
//! * setter argument is generic over [`Into`]
//! * [`Option`] fields are not mandatory. And setters use wrapped type.
//!
//! ### Settings
//!
//! Settings are set using `#[builder()]` attribute.
//!
//! #### struct
//!
//! * **`mode=<value>`** <br/>
//! Change builder and associated `build()` function behavior. Supported values: [`Typestate`](#typestate-pattern-default) (_default_), [`Panic`](#panic-on-build) or [`Result`](#result-on-build).
//!
//! * **`Default=!`** <br/>
//! Disable automatic [`Default`] derive detection for **struct**. See ["`Default` struct"](#default-struct).
//!
//! * **`Default`** <br/>
//! Enforce [`Default`] support for **struct**. See ["`Default` struct"](#default-struct).
//!
//! * **`Option=!`** (_deprecated. Use `fields(Option=!)` instead._)
//!
//! * **`Into=!`** (_deprecated. Use `fields(Into=!)` instead._)
//!
//! * **`fields(Option=!)`** <br/>
//! Disable automatic [`Option`] detection for **fields**. See ["`Option` fields"](#option-fields).
//!
//! * **`fields(Default=!)`** <br/>
//! Disable automatic [`Default`] detection for **fields**. See ["`Default` fields"](#default-fields).
//!
//! * **`fields(Into=!)`** <br/>
//! Disable [`Into`] for **fields**. See ["`Into` argument"](#into-argument).
//!
//! #### field
//!
//! * **`Option=!`** <br/>
//! Disable automatic [`Option`] detection for given field. Generated setter will rely on declared field type. See ["`Option` fields"](#option-fields).
//!
//! * **`Option=WrappedType`** <br/>
//! Enforce [`Option`] support for given field. Generated setter will rely on `WrappedType`. See ["`Option` fields"](#option-fields).
//!
//! * **`Default=!`** <br/>
//! Disable automatic [`Default`] detection for given field. See ["`Default` fields"](#default-fields).
//!
//! * **`Default`** <br/>
//! Enforce [`Default`] support for given field. See ["`Default` fields"](#default-fields).
//!
//! * **`Into=!`** <br/>
//! Disable [`Into`] for setter. See ["`Into` argument"](#into-argument).
//!
//! ### Features
//!
//! For any feature, you can find blueprints in [`./tests` directory][tests] showing code generated by macro.
//!
//! #### Typestate pattern (default)
//!
//! Blueprints:
//! * [`blueprint_typestate_named.rs`][blueprint_typestate_named.rs]
//! * [`blueprint_typestate_tuple.rs`][blueprint_typestate_tuple.rs]
//! * [`blueprint_typestate_option.rs`][blueprint_typestate_option.rs]
//! * [`blueprint_typestate_default_field.rs`][blueprint_typestate_default_field.rs]
//! * [`blueprint_typestate_default_struct.rs`][blueprint_typestate_default_struct.rs]
//!
//! By default, builder rely on typestate pattern. It means state is encoded in type (using generics). Applicable functions are implemented
//! (callable) only when state (type) matches:
//!
//! * Build function `build()` when all properties has been set
//! * Each property setter function as long as property haven't been set
//!
//! Optionally, you can set it explictly:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! #[builder(mode=Typestate)]
//! struct MyType {
//!   integer: i32,
//!   string: String,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn integer(self, value: i32) -> Self
//! # { unimplemented!(); }
//!   fn string(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> MyType
//! # { unimplemented!();  }
//! }
//! ```
//!
//! #### Panic on `build()`
//!
//! Blueprints:
//! * [`blueprint_panic_named.rs`][blueprint_panic_named.rs]
//! * [`blueprint_panic_tuple.rs`][blueprint_panic_tuple.rs]
//! * [`blueprint_panic_option.rs`][blueprint_panic_option.rs]
//! * [`blueprint_panic_default_field.rs`][blueprint_panic_default_field.rs]
//! * [`blueprint_panic_default_struct.rs`][blueprint_panic_default_struct.rs]
//!
//! By default, builder rely on typestate pattern to avoid misconfiguration by adding compilation constraint. You can switch to a builder
//! that just panic when misconfigured:
//!
//! ```should_panic
//! # #[macro_use] extern crate macon;
//! # use std::path::PathBuf;
//! #[derive(Builder)]
//! #[builder(mode=Panic)]
//! struct MyType {
//!   integer: i32,
//!   path: PathBuf,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn integer(self, value: i32) -> Self
//! # { unimplemented!(); }
//!   fn path(self, value: PathBuf) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> MyType
//! # { unimplemented!(); }
//! }
//!
//! let _mytype: MyType = MyType::builder()
//!     .integer(42)
//!     .build();
//! ```
//!
//! #### Result on `build()`
//!
//! Blueprints:
//! * [`blueprint_result_named.rs`][blueprint_result_named.rs]
//! * [`blueprint_result_tuple.rs`][blueprint_result_tuple.rs]
//! * [`blueprint_result_option.rs`][blueprint_result_option.rs]
//! * [`blueprint_result_default_field.rs`][blueprint_result_default_field.rs]
//! * [`blueprint_result_default_struct.rs`][blueprint_result_default_struct.rs]
//!
//! By default, builder rely on typestate pattern to avoid misconfiguration by adding compilation constraint. You can switch to a builder
//! that returns a [`Result`]:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! # use std::path::PathBuf;
//! #[derive(Builder)]
//! #[builder(mode=Result)]
//! struct MyType {
//!   integer: i32,
//!   path: PathBuf,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn integer(self, value: i32) -> Self
//! # { unimplemented!(); }
//!   fn path(self, value: PathBuf) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> Result<MyType, String>
//! # { unimplemented!(); }
//! }
//!
//! let myTypeResult: Result<MyType,String> = MyType::builder()
//!     .integer(42)
//!     .build();
//!
//! assert_eq!(
//!     Err(String::from("Field path is missing")),
//!     myTypeResult.map(|_| ())
//! );
//! ```
//!
//! #### Tuple
//!
//! Blueprints:
//! * [`blueprint_typestate_tuple.rs`][blueprint_typestate_tuple.rs]
//! * [`blueprint_panic_tuple.rs`][blueprint_panic_tuple.rs]
//! * [`blueprint_result_tuple.rs`][blueprint_result_tuple.rs]
//!
//! A tuple is a struct with unamed fields. Then `set<ordinal>()` is used as setter:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct MyTuple(
//!   i32,
//!   Option<String>,
//!   String,
//! );
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn set0(self, value: i32) -> Self
//! # { unimplemented!(); }
//!   fn set1(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn set2(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> MyTuple
//! # { unimplemented!(); }
//! }
//!
//! let _mytuple: MyTuple = MyTuple::builder()
//!     .set0(42)
//!     .set2(String::from("foobar"))
//!     .build();
//! ```
//!
//! Only for [`Typestate` mode](#typestate-pattern-default), you can chain `set()`, [`none()`](#option-fields), [`keep()`](#default-struct) and [`default()`](#default-fields) calls to assign values in order:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! # #[derive(Builder)]
//! # struct MyTuple(
//! #   i32,
//! #   Option<String>,
//! #   String,
//! # );
//!
//! // Builder signature
//! # struct Builder0;
//! impl Builder0 {
//!   fn set(self, value: i32) -> Builder1
//! # { unimplemented!(); }
//! }
//! # struct Builder1;
//! impl Builder1 {
//!   fn set(self, value: String) -> Builder2
//! # { unimplemented!(); }
//!   fn none(self) -> Builder2
//! # { unimplemented!(); }
//! }
//! # struct Builder2;
//! impl Builder2 {
//!   fn set(self, value: String) -> Builder
//! # { unimplemented!(); }
//! }
//! # struct Builder;
//! impl Builder {
//!   fn build(self) -> MyTuple
//! # { unimplemented!(); }
//! }
//!
//! let _mytuple: MyTuple = MyTuple::builder()
//!     .set(42)
//!     .none()
//!     .set(String::from("foobar"))
//!     .build();
//! ```
//!
//! #### `Into` argument
//!
//! Blueprints:
//! * [`blueprint_typestate_named.rs`][blueprint_typestate_named.rs]
//! * [`blueprint_panic_named.rs`][blueprint_panic_named.rs]
//! * [`blueprint_result_named.rs`][blueprint_result_named.rs]
//!
//! Setter function argument is generic over [`Into`] to ease conversion (especially for `&str`):
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct MyTuple(
//!   String,
//! );
//!
//! // Builder signature
//! # struct Builder0;
//! # struct Builder;
//! impl Builder0 {
//!   fn set<V: Into<String>>(self, value: V) -> Builder
//! # { unimplemented!(); }
//! }
//! impl Builder {
//!   fn build(self) -> MyTuple
//! # { unimplemented!(); }
//! }
//!
//! let _mytuple: MyTuple = MyTuple::builder()
//!     .set("foobar")
//!     .build();
//! ```
//!
//! You can disable [`Into`] support by using `#[builder(Into=!)]` at struct or field level:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! #[builder(Into=!)]     // Disable for all fields
//! struct IntoSettings {
//!   #[builder(Into=!)]   // Disable for specific field
//!   no_into: String,
//!   #[builder(Into)]     // Enable (only when disabled at struct level) for specific field
//!   with_into: String,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn no_into(value: String) -> Self
//! # { unimplemented!(); }
//!   fn with_into<V: Into<String>>(value: V) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> IntoSettings
//! # { unimplemented!(); }
//! }
//!
//! let built = IntoSettings::builder()
//!   .no_into(String::from("no value conversion"))
//!   .with_into("value conversion")
//!   .build();
//!
//! assert_eq!(String::from("no value conversion"), built.no_into);
//! assert_eq!(String::from("value conversion"), built.with_into);
//! ```
//!
//! This feature is required to use with [`dyn` trait](https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait):
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct DynTrait {
//!   #[builder(Into=!)]
//!   function: Box<dyn Fn(usize) -> usize>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn function(self, value: Box<dyn Fn(usize) -> usize>) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> DynTrait
//! # { unimplemented!(); }
//! }
//!
//! DynTrait::builder()
//!   .function(Box::new(|x| x + 1))
//!   .build();
//! ```
//!
//! #### Implement `Into`
//!
//! Blueprints:
//! * [`blueprint_typestate_named.rs`][blueprint_typestate_named.rs]
//! * [`blueprint_panic_named.rs`][blueprint_panic_named.rs]
//! * [`blueprint_result_named.rs`][blueprint_result_named.rs]
//!
//! Builders implement [`Into`] for target type (and reverse [`From`] also). Except for `Result` mode which uses [`TryInto`] / [`TryFrom`].
//!
//! ```
//! # #[macro_use] extern crate macon;
//! # #[derive(Builder)]
//! # struct MyStruct {
//! #   value: String,
//! # };
//! let _mytuple: MyStruct = MyStruct::builder()
//!     .value("foobar")
//!     .into();
//! ```
//!
//! #### `Option` fields
//!
//! Blueprints:
//! * [`blueprint_typestate_option.rs`][blueprint_typestate_option.rs]
//! * [`blueprint_panic_option.rs`][blueprint_panic_option.rs]
//! * [`blueprint_result_option.rs`][blueprint_result_option.rs]
//!
//! As their name suggests, [`Option`] fields are facultative: you can build instance without setting them explicitly.
//!
//! Setter argument are still generic over [`Into`] but for wrapped type. No need to wrap into an [`Option`]:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct WithOptional {
//!   mandatory: String,
//!   discretionary: Option<String>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn mandatory(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn discretionary(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> WithOptional
//! # { unimplemented!(); }
//! }
//!
//! let built = WithOptional::builder()
//!   .discretionary("optional value")
//!   .mandatory("some value")
//!   .build();
//!
//! assert_eq!(Some(String::from("optional value")), built.discretionary);
//! ```
//!
//! You can set them explicitly to [`None`](https://doc.rust-lang.org/core/option/enum.Option.html#variant.None) with `<field>_none()` or `none()` for ordered setter:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! pub struct WithOptional {
//!   mandatory: String,
//!   discretionary: Option<String>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn mandatory<V: Into<String>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn discretionary_none(self) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> WithOptional
//! # { unimplemented!(); }
//! }
//!
//! let built = WithOptional::builder()
//!   .discretionary_none()
//!   .mandatory("some value")
//!   .build();
//!
//! assert_eq!(None, built.discretionary);
//! ```
//!
//! <div class="warning">
//!
//! Note: In order to detect optional fields, field type **name** must match:
//!
//! * `core::option::Option`
//! * `::core::option::Option`
//! * `std::option::Option`
//! * `::std::option::Option`
//! * `Option`
//!
//! </div>
//!
//! You can disable [`Option`] support by using `#[builder(Option=!)]` at struct or field level:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! #[builder(Option=!)]
//! struct DisableOptionStruct {
//!   discretionary: Option<String>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn discretionary(self, value: Option<String>) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> DisableOptionStruct
//! # { unimplemented!(); }
//! }
//!
//! let built = DisableOptionStruct::builder()
//!   .discretionary(Some(String::from("mandatory value")))
//!   .build();
//!
//! assert_eq!(Some(String::from("mandatory value")), built.discretionary);
//! ```
//!
//! If you use an alias, use `#[builder(Option=<WrappedType>)]` at field level to enable [`Option`] support:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! type OptString = Option<String>;
//! #[derive(Builder)]
//! struct AliasedOptionStruct {
//!   #[builder(Option=String)]
//!   discretionary: OptString,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn discretionary(self, value: String) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> AliasedOptionStruct
//! # { unimplemented!(); }
//! }
//!
//! let built = AliasedOptionStruct::builder()
//!   .discretionary("aliased value")
//!   .build();
//!
//! assert_eq!(Some(String::from("aliased value")), built.discretionary);
//! ```
//!
//! If you are already dealing with [`Option`], use `<field>_optional` or `optional` for ordered setter:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct WithOptional {
//!   discretionary: Option<String>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn discretionary_optional(self, value: Option<String>) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> Self
//! # { unimplemented!(); }
//! }
//!
//! let discretionary = Some("any");
//! let built = WithOptional::builder()
//!   .discretionary_optional(discretionary)
//!   .build();
//!
//! assert_eq!(Some(String::from("any")), built.discretionary);
//! ```
//!
//! #### `Default` struct
//!
//! Blueprints:
//! * [`blueprint_typestate_default_struct.rs`][blueprint_typestate_default_struct.rs]
//! * [`blueprint_panic_default_struct.rs`][blueprint_panic_default_struct.rs]
//! * [`blueprint_result_default_struct.rs`][blueprint_result_default_struct.rs]
//!
//! If struct derives [`Default`], all fields are then optional and values are kept from default instance:
//!
//! <div class="warning">
//!
//! Note: In order to detect [`Default`] derive, `Builder` derive attribute must be placed before other derive attributes.
//!
//! </div>
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder,)]
//! #[derive(Default,PartialEq,Debug,)]
//! struct DeriveDefaultStruct {
//!   integer: usize,
//!   string: String,
//!   optional: Option<String>,
//! }
//!
//! let built = DeriveDefaultStruct::builder()
//!   .build();
//!
//! assert_eq!(
//!   DeriveDefaultStruct {
//!     integer: 0,
//!     string: String::from(""),
//!     optional: None,
//!   },
//!   built,
//! );
//! ```
//!
//! In case [`Default`] derive detection is undesired, you can disable it with `#[builder(Default=!)]`.
//!
//! On the other hand, if have your own [`Default`] implementation, you can add `#[builder(Default)]` to enable support.
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder,)]
//! #[derive(PartialEq,Debug,)]
//! #[builder(Default,)]
//! struct CustomDefaultStruct {
//!   integer: usize,
//!   string: String,
//!   optional: Option<String>,
//! }
//!
//! impl Default for CustomDefaultStruct {
//!     fn default() -> Self {
//!         CustomDefaultStruct {
//!             integer: 42,
//!             string: String::from("plop!"),
//!             optional: Some(String::from("some")),
//!         }
//!     }
//! }
//!
//! let built = CustomDefaultStruct::builder()
//!   .build();
//!
//! assert_eq!(
//!   CustomDefaultStruct {
//!     integer: 42,
//!     string: String::from("plop!"),
//!     optional: Some(String::from("some")),
//!   },
//!   built,
//! );
//! ```
//!
//! You can keep default value (from default built instance) explicitly with `<field>_keep()` or `keep()` for ordered setter:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! # #[derive(Builder,)]
//! # #[derive(PartialEq,Debug,)]
//! # #[builder(Default,)]
//! # struct CustomDefaultStruct {
//! #  integer: usize,
//! #  string: String,
//! #  optional: Option<String>,
//! # }
//! #
//! # impl Default for CustomDefaultStruct {
//! #     fn default() -> Self {
//! #         CustomDefaultStruct {
//! #             integer: 42,
//! #             string: String::from("plop!"),
//! #             optional: Some(String::from("some")),
//! #         }
//! #     }
//! # }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn integer<V: Into<usize>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn integer_keep(self) -> Self
//! # { unimplemented!(); }
//!   fn string<V: Into<String>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn string_keep(self) -> Self
//! # { unimplemented!(); }
//!   fn optional<V: Into<String>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn optional_none(self) -> Self
//! # { unimplemented!(); }
//!   fn optional_keep(self) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> CustomDefaultStruct
//! # { unimplemented!(); }
//! }
//!
//! let built = CustomDefaultStruct::builder()
//!   .integer_keep()
//!   .string("overriden")
//!   .optional_none()
//!   .build();
//!
//! assert_eq!(
//!   CustomDefaultStruct {
//!     integer: 42,
//!     string: String::from("overriden"),
//!     optional: None,
//!   },
//!   built,
//! );
//! ```
//!
//! #### `Default` fields
//!
//! Blueprints:
//! * [`blueprint_typestate_default_field.rs`][blueprint_typestate_default_field.rs]
//! * [`blueprint_panic_default_field.rs`][blueprint_panic_default_field.rs]
//! * [`blueprint_result_default_field.rs`][blueprint_result_default_field.rs]
//!
//! If field implements [`Default`], it is then optional and value is:
//!
//! 1. kept from default instance if [struct derives `Default`](#default-struct),
//! 1. or, initialized with default value.
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! #[derive(Debug,PartialEq,)]
//! struct WithDefaultFields {
//!   integer: usize,
//!   string: String,
//!   optional: Option<String>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn integer<V: Into<usize>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn integer_default(self) -> Self
//! # { unimplemented!(); }
//!   fn string<V: Into<String>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> WithDefaultFields
//! # { unimplemented!(); }
//! }
//!
//! let built = WithDefaultFields::builder()
//!   .build();
//!
//! assert_eq!(
//!   WithDefaultFields {
//!     integer: 0,
//!     string: String::from(""),
//!     optional: None,
//!   },
//!   built,
//! );
//! ```
//!
//! You can set them explicitly to default with `<field>_default()` or `default()` for ordered setter (e.g. [override default instance value](#default-struct)):
//!
//! ```
//! # #[macro_use] extern crate macon;
//! # #[derive(Builder)]
//! # #[derive(Debug,PartialEq,)]
//! # struct WithDefaultFields {
//! #   integer: usize,
//! #   string: String,
//! #   optional: Option<String>,
//! # }
//! #
//! let built = WithDefaultFields::builder()
//!   .integer_default()
//!   .string_default()
//!   .optional_default()
//!   .build();
//!
//! assert_eq!(
//!   WithDefaultFields {
//!     integer: 0,
//!     string: String::from(""),
//!     optional: None,
//!   },
//!   built,
//! );
//! ```
//!
//! <div class="warning">
//!
//! In order to detect default fields, field type **name** must match (leading `::` and module path are optionals):
//!
//! * `bool`
//! * `char`
//! * `f32`
//! * `f64`
//! * `i8`
//! * `i16`
//! * `i32`
//! * `i64`
//! * `i128`
//! * `isize`
//! * `str`
//! * `u8`
//! * `u16`
//! * `u32`
//! * `u64`
//! * `u128`
//! * `usize`
//! * `std::string::String`
//! * `core::option::Option`
//! * `std::option::Option`
//! * `std::vec::Vec`
//! * `alloc::vec::Vec`
//! * `std::collections::HashMap`
//! * `std::collections::hash_map::HashMap`
//! * `std::collections::HashSet`
//! * `std::collections::hash_set::HashSet`
//!
//! </div>
//!
//! If you use an alias or unsupported type, use `#[builder(Default)]` at field level to enable [`Default`] support:
//!
//! ```
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! #[derive(Debug,PartialEq,)]
//! struct ExplicitDefaultOnField {
//!   #[builder(Default)]
//!   boxed: Box<usize>,
//! }
//!
//! // Builder signature
//! # struct Builder;
//! impl Builder {
//!   fn boxed<V: Into<Box<usize>>>(self, value: V) -> Self
//! # { unimplemented!(); }
//!   fn boxed_default(self) -> Self
//! # { unimplemented!(); }
//!   fn build(self) -> ExplicitDefaultOnField
//! # { unimplemented!(); }
//! }
//!
//! let built = ExplicitDefaultOnField::builder()
//!     .build();
//!
//! assert_eq!(
//!   ExplicitDefaultOnField {
//!     boxed: Box::from(0),
//!   },
//!   built,
//! );
//! ```
//!
//! You can disable [`Default`] support by using `#[builder(Default=!)]` at field level:
//!
//! ```compile_fail
//! # #[macro_use] extern crate macon;
//! #[derive(Builder)]
//! struct DisableDefaultOnField {
//!   #[builder(Default=!)]
//!   integer: usize,
//! }
//!
//! DisableDefaultOnField::builder()
//!   .integer_default()
//!   .build();
//! ```
//!
//!
//! [tests]: https://github.com/loganmzz/macon-rs/tree/1.3.0/tests
//! [blueprint_panic_default_field.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_panic_default_field.rs
//! [blueprint_panic_default_struct.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_panic_default_struct.rs
//! [blueprint_panic_named.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_panic_named.rs
//! [blueprint_panic_option.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_panic_option.rs
//! [blueprint_panic_tuple.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_panic_tuple.rs
//! [blueprint_result_default_field.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_result_default_field.rs
//! [blueprint_result_default_struct.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_result_default_struct.rs
//! [blueprint_result_named.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_result_named.rs
//! [blueprint_result_option.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_result_option.rs
//! [blueprint_result_tuple.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_result_tuple.rs
//! [blueprint_typestate_default_field.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_typestate_default_field.rs
//! [blueprint_typestate_default_struct.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_typestate_default_struct.rs
//! [blueprint_typestate_named.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_typestate_named.rs
//! [blueprint_typestate_option.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_typestate_option.rs
//! [blueprint_typestate_tuple.rs]: https://github.com/loganmzz/macon-rs/blob/1.3.0/tests/blueprint_typestate_tuple.rs
//!

pub use ::macon_derive::*;
pub use ::macon_api::*;