Skip to content

Commit f9d60b6

Browse files
authored
fix nesting with other features (#100)
add nesting test for std,merge,none_as_default,keep_none features fix nesting with other features
1 parent 52f0a9d commit f9d60b6

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@ jobs:
3838
nix develop -c cargo run --features=std --example rename-patch-struct
3939
nix develop -c cargo run --features=std --example patch-attr
4040
nix develop -c cargo run --features=std --example option
41+
nix develop -c cargo run --features=std,nesting --example nesting
4142
nix develop -c cargo test --features=std
4243
4344
- name: Test with merge features
4445
run: |
4546
nix develop -c cargo run --features=option --features=merge --example option
4647
nix develop -c cargo run --features=merge --example op
48+
nix develop -c cargo run --features=merge,nesting --example nesting
4749
nix develop -c cargo test --features=merge --no-default-features
4850
nix develop -c cargo test --features=merge
4951
5052
- name: Test with option features
5153
run: |
5254
nix develop -c cargo run --features=none_as_default --example option
55+
nix develop -c cargo run --features=none_as_default,nesting --example nesting
5356
nix develop -c cargo run --features=keep_none --example option
57+
nix develop -c cargo run --features=keep_none,nesting --example nesting
5458
5559
- name: Test with default features
5660
run: |
5761
nix develop -c cargo run --example status
5862
nix develop -c cargo run --example op
63+
nix develop -c cargo run --features=nesting --example nesting
5964
nix develop -c cargo test

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77

88
[workspace.package]
99
authors = ["Antonio Yang <yanganto@gmail.com>"]
10-
version = "0.10.1"
10+
version = "0.10.2"
1111
edition = "2021"
1212
categories = ["development-tools"]
1313
keywords = ["struct", "patch", "macro", "derive", "overlay"]

struct-patch-derive/src/patch.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl Patch {
163163
#original_field_names: other.#original_field_names.or(self.#original_field_names),
164164
)*
165165
#(
166-
#nesting_field_names: other.#nesting_field_names.apply(self.#nesting_field_names),
166+
#nesting_field_names: other.#nesting_field_names.merge(self.#nesting_field_names),
167167
)*
168168
}
169169
}
@@ -228,6 +228,9 @@ impl Patch {
228228
(None, None) => None,
229229
},
230230
)*
231+
#(
232+
#nesting_field_names: self.#nesting_field_names + rhs.#nesting_field_names,
233+
)*
231234
}
232235
}
233236
}
@@ -277,6 +280,9 @@ impl Patch {
277280
(None, None) => None,
278281
},
279282
)*
283+
#(
284+
#nesting_field_names: self.#nesting_field_names + rhs.#nesting_field_names,
285+
)*
280286
}
281287
}
282288
}

struct-patch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license.workspace = true
1111
readme.workspace = true
1212

1313
[dependencies]
14-
struct-patch-derive = { version = "=0.10.1", path = "../struct-patch-derive" }
14+
struct-patch-derive = { version = "=0.10.2", path = "../struct-patch-derive" }
1515

1616
[dev-dependencies]
1717
serde_json = "1.0"

struct-patch/examples/nesting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
..Default::default()
3535
};
3636

37-
let patch = item_b.clone().into_patch_by_diff(item_a);
37+
let patch: ItemPatch = item_b.clone().into_patch_by_diff(item_a);
3838
assert_eq!(
3939
format!("{patch:?}"),
4040
"ItemPatch { field_complete: None, field_int: Some(7), field_string: None, inner: NestingPatch { inner_int: Some(100), inner_string: None } }"

0 commit comments

Comments
 (0)