| Crates.io | patched |
| lib.rs | patched |
| version | 0.3.0 |
| created_at | 2025-02-16 14:04:00.257993+00 |
| updated_at | 2025-02-18 19:55:39.47255+00 |
| description | Macro for patch like structure |
| homepage | |
| repository | https://github.com/tguichaoua/patched |
| max_upload_size | |
| id | 1557758 |
| size | 31,719 |
A macro that generates patch struct.
use patched::Patch;
#[derive(Patch)]
struct Foo {
a: u8,
b: String,
}
// Will generates
struct FooPatch {
a: Option<u8>
b: Option<String>,
}
impl Default for FooPatch {
/* ... */
}
impl Patch<FooPatch> for Foo {
/* ... */
}
Usage example:
let mut value = Foo {
a: 10,
b: String::from("Hello");
}
value.patch(FooPatch {
a: Some(99),
..Default::default()
});
assert_eq!(
value,
Foo {
a: 99,
b: String::from("Hello");
}
);