Crates.io | deep-struct-update |
lib.rs | deep-struct-update |
version | 0.1.0 |
source | src |
created_at | 2023-12-27 08:31:32.26941 |
updated_at | 2023-12-27 08:31:32.26941 |
description | Struct update syntax with nesting. |
homepage | |
repository | https://gitlab.com/konnorandrews/deep-struct-update |
max_upload_size | |
id | 1081517 |
size | 18,552 |
::deep-struct-update
Struct update syntax with support for nested structs.
use deep_struct_update::update;
struct Person {
name: String,
job: Job,
age: u8
}
struct Job {
position: String,
company: String
}
let bob = Person {
name: String::from("Bob"),
job: Job {
position: String::from("Programmer"),
company: String::from("Evil Inc.")
},
age: 29
};
let alice = update! {
name: String::from("Alice"),
age: 31,
job: {
position: String::from("Senior Programmer")
}
..bob
};
assert_eq!(alice.age, 31);
assert_eq!(alice.name, "Alice");
assert_eq!(alice.job.position, "Senior Programmer");
assert_eq!(alice.job.company, "Evil Inc.");