Skip to content

Commit f71caad

Browse files
committed
update readme
1 parent aebf3d5 commit f71caad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ A lib help you patch Rust instance, and easy to partial update configures.
99
This crate provides the `Patch`, `Filler` traits and accompanying derive macro.
1010
If the any field in `Patch` is some then it will overwrite the field of instance when apply.
1111
If the any field in the instance is none then it will try to fill the field with the `Filler`.
12-
Currently, `Filler` only support `Option` field, and the `Vec` and other field will implement later.
12+
Currently, `Filler` only support `Option` field and the `Vec`.
13+
The other fields and operator for Filler will implement later.
1314
The detail discussion is in [issue #81](https://github.com/yanganto/struct-patch/issues/81)
1415

1516
## Quick Example
@@ -73,21 +74,29 @@ use struct_patch::Filler;
7374
struct Item {
7475
field_int: usize,
7576
maybe_field_int: Option<usize>,
77+
list: Vec<uszie>,
7678
}
7779
let mut item = Item {
7880
field_int: 0,
7981
maybe_field_int: None,
82+
list: Vec::new(),
8083
};
8184

82-
let filler_1 = ItemFiller{ maybe_field_int: Some(7), };
85+
let filler_1 = ItemFiller{ maybe_field_int: Some(7), list: Vec::new() };
8386
item.apply(filler_1);
8487
assert_eq!(item.maybe_field_int, Some(7));
8588

86-
let filler_2 = ItemFiller{ maybe_field_int: Some(100), };
89+
let filler_2 = ItemFiller{ maybe_field_int: Some(100), list: Vec::new() };
8790

8891
// The field is not empty, so the filler has not effect.
8992
item.apply(filler_2);
9093
assert_eq!(item.maybe_field_int, Some(7));
94+
95+
let filler_3 = ItemFiller{ maybe_field_int: Some(100), list: vec![7] };
96+
97+
item.apply(filler_3);
98+
assert_eq!(item.maybe_field_int, Some(7));
99+
assert_eq!(item.list, vec![7]);
91100
```
92101

93102
## Documentation and Examples

0 commit comments

Comments
 (0)