Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions website/src/guide/troubleshooting/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ fn example(

Here is [the related issue](https://github.com/rust-lang/rustfmt/issues/6276) in `rustfmt` about this problem.

## `const` Functions
## `const` Evaluation

It's possible to place `#[builder]` on top of a `const fn`, but the generated builder methods won't be marked `const`. They use the non-const method `Into::into` to transition between type states. Except for that, the generated code should be `const`-compatible.
It's possible to place `#[builder]` on top of a `const fn`, but the generated builder methods won't be marked as `const`. Note that even if `bon` adds support for `const` builders, some features won't work for them. For example:

If you have a strong use case that requires full support for `const`, feel free to [open an issue]. We'll figure something out for sure 🐱.
- `#[builder(default)]` can not work because `Default::default()` is not `const`. You'd have to write `#[builder(default = ...)]` instead to construct the default value manually
- `#[builder(into)]` can not work because `Into::into()` is not `const`

If you have a strong use case that requires full support for `const`, feel free to leave a 👍 on [this issue](https://github.com/elastio/bon/issues/169).

[open an issue]: https://github.com/elastio/bon/issues
2 changes: 1 addition & 1 deletion website/src/guide/typestate-api/builder-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ assert_eq!(x1, 99);

## Custom Fields

This is useful if you'd like a completely custom state for [custom setters](./custom-methods) in the builder.
Custom fields are useful if you'd like a completely custom state for [custom setters](./custom-methods) in the builder.

To understand how it works, we'll create a builder API _similar_ to [`std::process::Command`](https://doc.rust-lang.org/stable/std/process/struct.Command.html) where you have a couple of methods [`arg`](https://doc.rust-lang.org/stable/std/process/struct.Command.html#method.arg) and [`args`](https://doc.rust-lang.org/stable/std/process/struct.Command.html#method.args), that push values into an internal arguments `Vec`.

Expand Down