use component_model ::Assign;
#[ derive( Default, Debug, PartialEq, Assign ) ]
struct NetworkConfig
{
host: String,
port: i32,
}
#[ derive( Default, Debug, PartialEq, Assign ) ]
struct UserProfile
{
username: String,
user_id: i32,
}
fn main()
{
println!( "=== Advanced Assignment Patterns ===" );
let mut net_config = NetworkConfig ::default();
net_config.assign( "api.example.com" );
net_config.assign( 443 );
println!( "Network config: {net_config:?}" );
let user_profile = UserProfile ::default()
.impute( "alice_dev" )
.impute( 1001 );
println!( "User profile: {user_profile:?}" );
let mut mixed_config = NetworkConfig ::default();
mixed_config.assign( 8080 ); mixed_config.assign( "localhost" );
println!( "Mixed assignment: {mixed_config:?}" );
let user1 = UserProfile ::default()
.impute( "bob_user" ) .impute( 2002 );
let user2 = UserProfile ::default()
.impute( 2002 ) .impute( "bob_user" );
assert_eq!( user1, user2 );
println!( "Order-independent assignment: {user1:?} == {user2:?}" );
assert_eq!( mixed_config.host, "localhost" );
assert_eq!( mixed_config.port, 8080 );
assert_eq!( user_profile.username, "alice_dev" );
assert_eq!( user_profile.user_id, 1001 );
println!( "✅ Advanced assignment patterns complete!" );
}