-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
89 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ members = [ | |
|
||
[workspace.package] | ||
authors = ["Antonio Yang <[email protected]>"] | ||
version = "0.5.0" | ||
version = "0.6.0" | ||
edition = "2021" | ||
categories = ["development-tools"] | ||
keywords = ["struct", "patch", "macro", "derive", "overlay"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use struct_patch::Patch; | ||
use serde_with::skip_serializing_none; | ||
|
||
#[derive(Default, Patch)] | ||
#[patch_derive(serde::Serialize, Debug, Default)] | ||
#[patch_attribute(skip_serializing_none)] | ||
struct Item { | ||
field_bool: bool, | ||
field_int: usize, | ||
field_string: String, | ||
} | ||
|
||
// Generated by Patch derive macro | ||
// | ||
// #[derive(Debug, Default)] // pass by patch_derive | ||
// #[skip_serializing_none] // pass by patch_attribute | ||
// struct ItemPatch { // pass by patch_name | ||
// field_bool: Option<bool>, | ||
// field_int: Option<usize>, | ||
// field_string: Option<String>, | ||
// } | ||
|
||
fn main() { | ||
let patch = Item::new_empty_patch(); | ||
|
||
assert_eq!( | ||
format!("{patch:?}"), | ||
"ItemPatch { field_bool: None, field_int: None, field_string: None }" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters