Typed Builder
🤔 Refer to Builder with typestate in Rust
Do
- Use Typed Builder
use typed_builder::TypedBuilder; #[derive(Debug, TypedBuilder)] struct User { id: String, email: String, #[builder(default)] first_name: Option<String>, #[builder(default)] last_name: Option<String>, } fn main() { let katopz = User::builder() .id("13".into()) .email("[email protected]".into()) .first_name(Some("Kat".into())) .build(); println!("{katopz:?}"); }