//! Comprehensive example of the generated builder and its typestate API.
//!
//! The preliminary reading of [Typestate API](https://bon-rs.com/guide/typestate-api)
//! guide is recommended to understand how the pieces in this example fit together.
//!
//! This module contains a struct [`Example`] that was annotated with [`#[derive(Builder)]`](bon::Builder).
//! The config [`#[builder(state_mod(vis = "pub"))]`](https://bon-rs.com/reference/builder/top-level/state_mod)
//! was applied to make the generated builder's typestate API public and visible here in the docs.
//!
//! The following was generated by the macro:
//! - [`ExampleBuilder`] - the builder struct itself
//! - [`example_builder`] - the builder's typestate API module

/// Example struct with the `#[derive(Builder)]` annotation.
#[derive(bon::Builder)]
#[builder(state_mod(vis = "pub"))]
pub struct Example {
    required: u32,

    optional: Option<u32>,

    #[builder(default)]
    default: u32,

    #[builder(overwritable)]
    overwritable_required: u32,

    #[builder(overwritable)]
    overwritable_optional: Option<u32>,

    #[builder(overwritable, default = 2 * 2 + 3)]
    overwritable_default: u32,

    #[builder(required)]
    required_option: Option<u64>,

    #[builder(with = |x: &str| -> Result<_, std::num::ParseIntError> { x.parse() })]
    with: u32,
}
