Skip to content

Commit

Permalink
doc: Document builder init argument
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed Nov 22, 2024
1 parent 907c5bc commit 66d426e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fieldx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,18 @@
//! - **`attributes`** (see the [section above](#attrs_family)) – builder struct attributes
//! - **`attributes_impl`** - attributes of the struct implementation
//! - **`into`** – force all builder setter methods to attempt automatic type conversion using `.into()` method
//! - **`opt_in`** - struct-level only argument; with it only fields with explicit `builder` can get their values from the builder
//!
//! With `into` the example above wouldn't need `String::from` and the call could look like this:
//! `.description("some description")`
//! - **`opt_in`** - struct-level only argument; with it only fields with explicit `builder` can get their values from the builder
//! - **`init`** - struct-level only argument; specifies identifier of the method to call to finish object initialization.
//!
//! There are a couple of notes to take into account:
//!
//! - the method is called on freshly created object right before it is returned back to builder caller
//! - it must take and return `self`: `fn post_build(mut self) { self.foo = "bar"; self }`
//! - for reference-counted structs the method is invoked before they're wrapped into corresponding container;
//! this allows for `mut self` and direct access to the fields without use of inner mutability
//!
//! ### **`rc`**
//!
Expand Down Expand Up @@ -743,12 +751,12 @@
//!
//! ### **`builder`**
//!
//! **Type**: function
//! **Type**: helper
//!
//! Mostly identical to the [struct-level `builder`](#builder). Field specifics are:
//!
//! - no `attributes_impl` and `opt_in` (consumed, but ignored)
//! - string literal specifies setter method name if the builder type for this field
//! - string literal specifies setter method name of the builder type for this field
//! - `attributes` and `attributes_fn` are correspondingly applies to builder field and builder setter method
//!
//! Field level only argument:
Expand Down

0 comments on commit 66d426e

Please sign in to comment.