# Patched
[](https://github.com/tguichaoua/patched)
[](https://crates.io/crates/patched)
[](https://docs.rs/patched)
[](https://github.com/tguichaoua/patched/blob/main/LICENSE-MIT)
[](https://github.com/tguichaoua/patched/blob/main/LICENSE-APACHE)
A macro that generates patch struct.
```rust
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:
```rs
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");
}
);
```