Skip to content

Commit

Permalink
refactor!: Refactor to make easy improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara committed Jul 31, 2024
1 parent 947551e commit 264837d
Show file tree
Hide file tree
Showing 11 changed files with 444 additions and 304 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use struct_patch::Patch;
use serde::{Deserialize, Serialize};

#[derive(Default, Debug, PartialEq, Patch)]
#[patch_derive(Debug, Default, Deserialize, Serialize)]
#[patch(attribute(derive(Debug, Default, Deserialize, Serialize)))]
struct Item {
field_bool: bool,
field_int: usize,
Expand Down Expand Up @@ -51,7 +51,17 @@ fn patch_json() {
```

## Documentation and Examples
Also, you can modify the patch structure by `#[patch_attribute(...)]`, `#[patch_derive(...)]`, `#[patch_name = "..."]` and `#[patch_skip]`.
Also, you can modify the patch structure by defining `#[patch(...)]` attributes on the original struct or fields.

Struct attributes:
- `#[patch(name = "...")]`: change the name of the generated patch struct.
- `#[patch(attribute(...))]`: add attributes to the generated patch struct.

Field attributes:
- `#[patch(skip)]`: skip the field in the generated patch struct.
- `#[patch(type = "...")]`: change the type of the field in the generated patch struct.
- `#[patch(attribute(...))]`: add attributes to the field in the generated patch struct.

Please check the [traits][doc-traits] of document to learn more.

The [examples][examples] demo following scenarios.
Expand Down
3 changes: 3 additions & 0 deletions struct-patch-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ syn = { version = "2.0", features = ["parsing"] }

[features]
status = []

[dev-dependencies]
pretty_assertions_sorted = "1.2.3"
Loading

0 comments on commit 264837d

Please sign in to comment.