//! ## Example : Trivial //! //! The provided code snippet illustrates a basic use-case of the Former, which is used to apply the builder pattern for to construct complex objects step-by-step, ensuring they are always in a valid state and hiding internal structures. //! #[ cfg( any( not( feature = "derive_former" ), not( feature = "enabled" ) ) ) ] fn main() {} #[ cfg( all( feature = "derive_former", feature = "enabled" ) ) ] fn main() { use former::Former; // Use attribute debug to print expanded code. #[ derive( Debug, PartialEq, Former ) ] // Uncomment to see what derive expand into // #[ debug ] pub struct UserProfile { age : i32, username : String, bio_optional : Option< String >, // Fields could be optional } let profile = UserProfile::former() .age( 30 ) .username( "JohnDoe".to_string() ) .bio_optional( "Software Developer".to_string() ) // Optionally provide a bio .form(); dbg!( &profile ); // Expected output: // &profile = UserProfile { // age: 30, // username: "JohnDoe", // bio_optional: Some("Software Developer"), // } }