Struct Patch
A lib help you patch Rust instance, and easy to partial update configures.
Introduction
This crate provides the Patch
trait and an accompanying derive macro.
Deriving Patch
on a struct will generate a struct similar to the original one, but with all fields wrapped in an Option
.
An instance of such a patch struct can be applied onto the original struct, replacing values only if they are set to Some
, leaving them unchanged otherwise.
Quick Example
use Patch;
use ;
Documentation and Examples
Also, you can modify the patch structure by #[patch_attribute(...)]
, #[patch_derive(...)]
, #[patch_name = "..."]
and #[patch_skip]
.
Please check the traits of document to learn more.
The examples demo following scenarios.
- diff two instance for a patch
- create a patch from json string
- rename the patch structure
- check a patch is empty or not
- add attribute to patch struct