Skip to content

Commit 065f8b6

Browse files
committed
Remove some embarrassing humor from the alternatives docs
1 parent 803b028 commit 065f8b6

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

website/src/guide/alternatives.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,33 +87,32 @@ Line::builder().x1(1).y1(2).x2(3).y2(4).build(); // [!code error]
8787

8888
There are two problems with `#[derive(Builder)]` syntax in this case:
8989

90-
1. This refactoring becomes a breaking change to `Line`'s builder API 😢.
91-
2. The private utility `Point` type leaks through the builder API via `point1`, and `point2` setters 😭.
90+
1. This refactoring becomes a breaking change to `Line`'s builder API.
91+
2. The private utility `Point` type leaks through the builder API via `point1`, and `point2` setters.
9292

9393
The fundamental problem is that the builder's API is _coupled_ ⛓️ with your struct's internal representation. It's literally `derive`d from the fields of your struct.
9494

9595
### Suffering
9696

9797
If you were using `typed-builder` or `derive_builder`, you'd be stuck for a while trying to find the magical 🪄 combination of attributes that would let you do this change without breaking compatibility or leakage of the private `Point` type.
9898

99-
With no solution in sight 😮‍💨, you'd then fall back to writing the same builder manually. You'd probably expand the builder derive macro and edit the generated code directly, which, ugh... hurts 🤕.
99+
With no solution in sight, you'd then fall back to writing the same builder manually. You'd probably expand the builder derive macro and edit the generated code directly, which, ugh... hurts.
100100

101-
However, that would be especially painful with `typed-builder`, which generates a complex typestate that is not human-readable and maintainable enough by hand. It also references some internal `#[doc(hidden)]` symbols from the `typed-builder` crate. Achoo... 🤧.
101+
However, that would be especially painful with `typed-builder`, which generates a complex typestate that is not human-readable and maintainable enough by hand. It also references some internal `#[doc(hidden)]` symbols from the `typed-builder` crate.
102102

103103
::: tip
104104

105-
In contrast, `bon`'s type state **is** human-readable, maintainable, and [documented](./typestate-api) 👍
105+
In contrast, `bon`'s type state **is** human-readable, maintainable, and [documented](./typestate-api)
106106

107107
:::
108108

109109
### Behold the Function-Based Builder
110110

111-
This change is as simple as pie 🥧 with `bon` or `buildstructor`. The code speaks for itself:
111+
This change is as simple as pie with `bon` or `buildstructor`. You need no more derives on a struct. Its internal representation can be decoupled from the builder by deriving the builder from a method:
112112

113113
```rust
114114
use bon::bon;
115115

116-
// No more derives on a struct. Its internal representation is decoupled from the builder.
117116
pub struct Line {
118117
point1: Point,
119118
point2: Point,
@@ -139,19 +138,15 @@ impl Line {
139138
Line::builder().x1(1).y1(2).x2(3).y2(4).build();
140139
```
141140

142-
Ah... Isn't this just so simple and beautiful? 😌 The fun part is that the constructor method `new` that we originally abandoned comes back to heroically save us ⛑️ at no cost, other than a star ⭐ on `bon`'s [Github repo](https://github.com/elastio/bon) maybe 🐈?
143-
144-
And you know what, our old friend `new` doesn't feel offended for being abandoned. It doesn't even feel emotions, actually 🗿. But it's happy to help you 🫂.
145-
146-
Moreover, it offers you a completely new dimension of flexibility:
141+
Moreover, this approach offers you a completely new dimension of flexibility:
147142

148143
- Need some validation? Just change the `new()` method to return a `Result`. The generated `build()` method will then become fallible.
149144
- Need to do an `async` operation in the constructor? Just make your constructor `async` and your `build()` will return a `Future`.
150145
- Need some adrenaline 💉? Just add `unsafe`, and... you get the idea 😉.
151146

152147
---
153148

154-
The chances of hitting a wall with function builders are close to zero, and even if you ever do, you still have access to the [Typestate API](./typestate-api) in `bon` for even more flexibility 💪.
149+
The chances of hitting a wall with function builders are close to zero, and even if you ever do, you still have access to the [Typestate API](./typestate-api) in `bon` for even more flexibility.
155150

156151
## Generated Docs Comparison
157152

0 commit comments

Comments
 (0)