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
//! Bauer is a crate for automatically generating Builder-patterns for your structs!
//!
//! Not sure what kind of builder you want? Bauer supports a variety of sub-patterns: Owned,
//! Borrowed, and even Type-State!
//!
//! # Examples
//!
//! ```rust
//! # use bauer::Builder;
//! #[derive(Builder)]
//! #[builder(kind = "type-state")]
//! pub struct Foo {
//! required_field: u32,
//! #[builder(default)]
//! default_field: u32,
//! #[builder(into)]
//! converting_field: String,
//! #[builder(repeat)]
//! repeating_field: Vec<u32>,
//! #[builder(repeat, repeat_n = 1..=3)]
//! limited_repeating_field: Vec<u32>,
//! }
//!
//! let foo: Foo = Foo::builder()
//! .required_field(42)
//! // .default_field(69) // defaults to 0
//! .converting_field("hello world") // calls `.into()` to convert from &str -> String
//! .repeating_field(420)
//! .repeating_field(1337)
//! .limited_repeating_field(0) // If not called 1..=3 times, this will fail
//! .build();
//! ```
//!
//! Check out [the repository](https://github.com/funnyboy-roks/bauer/tree/main/examples) for more
//! examples!
//!
//! # Configuration
//!
//! Builders are very configurable. A few of the biggest features can be found below. For a more
//! comprehensive collection of features, look at the [`Builder`] macro.
//!
//! ## Kinds
//!
//! Bauer supports generating 3 kinds of builders:
//!
//! ### **Owned** (default) / **Borrowed**
//!
//! `"owned"` builders are passed around by value and `"borrowed"` builders are passed by mutable
//! reference.
//!
//! ### **Type-State**
//!
//! `"type-state"` builders use the type-state pattern and generate builds that are validated at
//! compile-time using the type system.
//!
//! Builder kinds can be switched between trivially using `#[builder(kind = <kind>)]` on the
//! struct.
//!
//! ## Field Attributes
//!
//! These attributes go in `#[builder(..)]` on individual fields of the structure
//!
//! ### **`default`**
//!
//! Specify a default value for the field to have, or use [`Default::default`]
//!
//! ### **`repeat`**
//!
//! Allow any structure which supports [`FromIterator`] to be specified by calling the function
//! multiple times. If `repeat_n` is specified, the number of times to repeat is limited.
//!
//! ### **`into`**/**`tuple`**/**`adapter`**
//!
//! Change how the generated builder function handles input. Can also be used with `repeat`.
//!
//! - `into` will make the function accepet `impl Into<T>`
//! - `tuple` will make the function accept each item as a separate argument
//! - `adapter` can specify each argument and how they should be converted into the value
//!
//! **There are many more attributes, all can be found on the [`Builder`] macro.**
//!
//! [`Builder`]: https://docs.rs/bauer/latest/bauer/derive.Builder.html
pub use *;