treediff-5.0.0/.cargo_vcs_info.json 0000644 00000000136 00000000001 0012626 0 ustar {
"git": {
"sha1": "9c260be9518e20239f5aedf5c1fae1a550889c94"
},
"path_in_vcs": ""
} treediff-5.0.0/CHANGELOG.md 0000644 0000000 0000000 00000070112 10461020230 0013230 0 ustar 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 5.0.0 (2024-03-27)
### Bug Fixes (BREAKING)
- replace unmaintained yaml-rust 0.4 with yaml-rust2 0.8
This may be a breaking change for some, hence the major version bump.
### Commit Statistics
- 2 commits contributed to the release.
- 53 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Replace unmaintained yaml-rust 0.4 with yaml-rust2 0.8 ([`3e665df`](https://github.com/byron/treediff-rs/commit/3e665df3999895329fc12920f33acaf802723424))
- Replace unmaintained yaml-rust ([`5833bcd`](https://github.com/byron/treediff-rs/commit/5833bcd4fe7fa64a1940046e1b8b4612040b87c1))
## 4.0.3 (2024-02-03)
This release updates serde-yaml to v0.9.
### Commit Statistics
- 4 commits contributed to the release over the course of 1 calendar day.
- 847 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release treediff v4.0.3 ([`d8ae624`](https://github.com/byron/treediff-rs/commit/d8ae624097dd82438aaa4022c1bfd8b9ca4c74df))
- Prepare changelog prior to release ([`d61b90c`](https://github.com/byron/treediff-rs/commit/d61b90ca0dfce93d5c58567ed029ac7c319b0c8a))
- Merge pull request #13 from glehmann/serde-yaml-09 ([`d480652`](https://github.com/byron/treediff-rs/commit/d480652f79a9853340dfdfed462b195400a4255f))
- Update serde_yaml to 0.9 ([`3177d4a`](https://github.com/byron/treediff-rs/commit/3177d4a6fc8226fa3fdfef656f934db0b75db541))
## v4.0.2 (2021-10-09)
* update changelog
### Commit Statistics
- 2 commits contributed to the release.
- 1 day passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release treediff v4.0.2 ([`41c9caf`](https://github.com/byron/treediff-rs/commit/41c9caf8622f860a1cd782f7a450da1786be78e9))
- Prepare changelog for next release ([`716c87e`](https://github.com/byron/treediff-rs/commit/716c87eca34623dcd0ac063b07d75e241f8149eb))
## v4.0.1 (2021-10-07)
* fix links in documentation (#8)
### Commit Statistics
- 12 commits contributed to the release over the course of 613 calendar days.
- 613 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release treediff v4.0.1 ([`ebf1d8b`](https://github.com/byron/treediff-rs/commit/ebf1d8ba93e5c59425ac27f3915143c78293807b))
- Adjusting Changelogs prior to release of treediff v4.0.1 ([`02db0ae`](https://github.com/byron/treediff-rs/commit/02db0ae6baf987e670d711eed01e69db9ca9dd42))
- Cleanup changelog ([`20e2e0e`](https://github.com/byron/treediff-rs/commit/20e2e0e975d5257a8797455c477b45b9d8eeeea7))
- Rename changelog to capitalized version. ([`12ad31b`](https://github.com/byron/treediff-rs/commit/12ad31ba673cee921250891d792e6f89eb5dedcf))
- Fix broken doc comments. ([`8f28c92`](https://github.com/byron/treediff-rs/commit/8f28c9294f91296724d88a0217b8d908a4b41008))
- Fix serde_yaml tests - for some reason it inserts newlines to key values ([`6d524b4`](https://github.com/byron/treediff-rs/commit/6d524b42f25822846f45bcd345d400c494b387ba))
- Fix most of the clippy warnings ([`223ef3c`](https://github.com/byron/treediff-rs/commit/223ef3c8a2627ac2e564bb561799f28b883f8aa3))
- Remove 'alpha' from next version string ([`27ec50b`](https://github.com/byron/treediff-rs/commit/27ec50ba7d38efd99d2a97a5e7d1463171a103ec))
- Optimize imports ([`a52269e`](https://github.com/byron/treediff-rs/commit/a52269ed292315a64dcba635c4be86222b6bc416))
- Bye bye travis, it was a good time ([`c44db69`](https://github.com/byron/treediff-rs/commit/c44db69473b837970fb555297e43eba67bddc8ad))
- Create rust.yml ([`7bfefb5`](https://github.com/byron/treediff-rs/commit/7bfefb520ed5164004873cb54e429a3d3213f0b4))
- (cargo-release) start next development iteration 4.0.1-alpha.0 ([`ab3a679`](https://github.com/byron/treediff-rs/commit/ab3a67951fd606c07018c7d12bfd674c90f453d8))
## v4.0.0 (2020-02-02)
### Commit Statistics
- 3 commits contributed to the release.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Fix all lints ([`0ffb242`](https://github.com/byron/treediff-rs/commit/0ffb2428fbe7f138b022568d5b659b39037524e7))
- Upgrade serde-yaml to the latest version ([`3bcb5bb`](https://github.com/byron/treediff-rs/commit/3bcb5bb53e55bbd4efd5eb4c81bec3ea7c876186))
- (cargo-release) start next development iteration 3.0.3-alpha.0 ([`ffc085e`](https://github.com/byron/treediff-rs/commit/ffc085e46f729befee22e327d45ec595bd38cebc))
## v3.0.2 (2020-02-02)
### Commit Statistics
- 2 commits contributed to the release.
- 690 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Rust 2018 upgrades ([`e126c32`](https://github.com/byron/treediff-rs/commit/e126c32cdfdff2f598a09dfdd45e192f27ae50a7))
- Remove clog; smaller package ([`176cd69`](https://github.com/byron/treediff-rs/commit/176cd69361b19fd882386cb797be8ba467047404))
## v3.0.1 (2018-03-12)
### Commit Statistics
- 1 commit contributed to the release.
- 1 day passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Make filter_mut() actually return a mutable reference ([`cbb1b06`](https://github.com/byron/treediff-rs/commit/cbb1b06745397ec05503b20542c7839e0c55ca19))
## v3.0.0 (2018-03-11)
* **upgrade**: use latest versions of dependencies
### Commit Statistics
- 2 commits contributed to the release over the course of 87 calendar days.
- 168 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Update to latest versions of dependencies ([`0517e7c`](https://github.com/byron/treediff-rs/commit/0517e7cfa60256a73845a30122931c5ade389fb5))
- Apply latest rustfmt ([`ace2602`](https://github.com/byron/treediff-rs/commit/ace26024b175c0f2ca28ecc0901a13dd3ec92158))
## v2.5.3 (2017-09-24)
### Commit Statistics
- 3 commits contributed to the release over the course of 30 calendar days.
- 214 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Version bump ([`e0167bd`](https://github.com/byron/treediff-rs/commit/e0167bd28787375b6b2027e61ab40462e6bfa236))
- Merge pull request #3 from paulrouget/serde_bump ([`dbac9ec`](https://github.com/byron/treediff-rs/commit/dbac9ec4f02714a8c016d4658b404a6cee1b035c))
- Serde version bump ([`fe8f02a`](https://github.com/byron/treediff-rs/commit/fe8f02a857ec17c6bd05b7a2f717d2ab50242e3a))
## v2.5.1 (2017-02-22)
### Other
- use serde 0.9.8 and Map::Entry
* **upgrade:** use serde 0.9.8 and Map::Entry ([60923752](https://github.com/Byron/treediff-rs/commit/6092375279e6fe184c8b457f0e6eb5a9f7f05d3b))
### Commit Statistics
- 2 commits contributed to the release.
- 7 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Update changelog ([`323a20f`](https://github.com/byron/treediff-rs/commit/323a20fa362c1f01cef00dc1d9bc19995adc621a))
- Use serde 0.9.8 and Map::Entry ([`6092375`](https://github.com/byron/treediff-rs/commit/6092375279e6fe184c8b457f0e6eb5a9f7f05d3b))
## v2.5.0 (2017-02-14)
### Other
- allow keys to be cloned and displayed
* **merger:** allow keys to be cloned and displayed ([75fae1b2](https://github.com/Byron/treediff-rs/commit/75fae1b2c30b9ce42012f1c9d63118e0443b9b6f))
### Commit Statistics
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- V2.5.0 ([`727ed22`](https://github.com/byron/treediff-rs/commit/727ed22fddba6a58ec654db1b0474f7a8f8c9444))
- Allow keys to be cloned and displayed ([`75fae1b`](https://github.com/byron/treediff-rs/commit/75fae1b2c30b9ce42012f1c9d63118e0443b9b6f))
## v2.4.0 (2017-02-14)
### Other
- method to obtain mutable borrow to filter
- method to obtain immutable reference to filter.
* **merger:**
* method to obtain mutable borrow to filter ([eeb3a2da](https://github.com/Byron/treediff-rs/commit/eeb3a2da52c22d7e820fe3a40c74e55a2431ff9e))
* method to obtain immutable reference to filter. ([fc210ea4](https://github.com/Byron/treediff-rs/commit/fc210ea42354be6e8febcd210bd9630040bd357d))
* method to obtain immutable reference to filter. ([fc210ea4](https://github.com/Byron/treediff-rs/commit/fc210ea42354be6e8febcd210bd9630040bd357d))
### Commit Statistics
- 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- V2.4.0 ([`960d01c`](https://github.com/byron/treediff-rs/commit/960d01c122bd51f2e120aa59217feae7fee77731))
- Method to obtain mutable borrow to filter ([`eeb3a2d`](https://github.com/byron/treediff-rs/commit/eeb3a2da52c22d7e820fe3a40c74e55a2431ff9e))
- Method to obtain immutable reference to filter. ([`fc210ea`](https://github.com/byron/treediff-rs/commit/fc210ea42354be6e8febcd210bd9630040bd357d))
## v2.3.0 (2017-02-13)
### Other
- handle possiblity of underflow
- add AsRef implementation
* **Merger:** add AsRef implementation ([981c94af](https://github.com/Byron/treediff-rs/commit/981c94afe98cd1da11aed290562ebe4a1e7a60cc))
* **safety:** handle possiblity of underflow ([07eff4f9](https://github.com/Byron/treediff-rs/commit/07eff4f93816bc10d4b0d5d98bcaef03741ee2c0))
### Commit Statistics
- 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Update changelog ([`49cdef0`](https://github.com/byron/treediff-rs/commit/49cdef0719b3824f5c58f0eda65be18728bde84a))
- Handle possiblity of underflow ([`07eff4f`](https://github.com/byron/treediff-rs/commit/07eff4f93816bc10d4b0d5d98bcaef03741ee2c0))
- Add AsRef implementation ([`981c94a`](https://github.com/byron/treediff-rs/commit/981c94afe98cd1da11aed290562ebe4a1e7a60cc))
## v2.2.0 (2017-02-13)
* `yaml_rust` support, for both `diff` and `merge`.
### Commit Statistics
- 2 commits contributed to the release.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Bump to version 2.2 ([`3c0dc31`](https://github.com/byron/treediff-rs/commit/3c0dc310456aa6a6e8b0dd1d9fe90c183ccf98ae))
- Support for yaml-rust ([`88b632d`](https://github.com/byron/treediff-rs/commit/88b632d0e3906680fd22f0fd3ea7ab7f077f5f65))
## v2.1.1 (2017-02-13)
### Other
- fix links
* fix library documentation links
### Commit Statistics
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Fix links ([`f061028`](https://github.com/byron/treediff-rs/commit/f06102825d04bf245b5ff2ee931e8a45b94e9dd3))
## v2.1.0 (2017-02-13)
* `serde_yaml` support, for both `diff` and `merge`.
### Commit Statistics
- 3 commits contributed to the release.
- 6 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Mutator/merge support for serde-yaml ([`5e44fe9`](https://github.com/byron/treediff-rs/commit/5e44fe965d163ea5a833ddebe468759177f31083))
- Prepare merge tests for Yaml ([`e132c25`](https://github.com/byron/treediff-rs/commit/e132c25fc0117ffcc540772725867be7ebb536f7))
- Add diff support for serde-yaml ([`8e14a85`](https://github.com/byron/treediff-rs/commit/8e14a85f15a323f27d2ed3866c1bad6dd206053a))
## v2.0.1 (2017-02-07)
### Other
- categories!
* **cargo:** categories! ([4dc20325](https://github.com/Byron/treediff-rs/commit/4dc2032561593cee1a41f2371396fade9687906c))
### Commit Statistics
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Update changelog ([`ed7c873`](https://github.com/byron/treediff-rs/commit/ed7c87357a6ac8a59b962bbd7ce8ab63b3639bca))
- Categories! ([`4dc2032`](https://github.com/byron/treediff-rs/commit/4dc2032561593cee1a41f2371396fade9687906c))
- Say goodbye to git-journal, welcome back clog ([`67797d3`](https://github.com/byron/treediff-rs/commit/67797d328e1adc1d22268cb5b3a95d73fe221a74))
## v2.0.0 (2017-02-07)
Improve `Merger` API considerably, and make it even more powerful.
### Commit Statistics
- 3 commits contributed to the release over the course of 1 calendar day.
- 1 day passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Bumped version to v2.0 ([`a579c1c`](https://github.com/byron/treediff-rs/commit/a579c1c051dabd0846a495cbeadef1b70a4987e7))
- Improved merger API ([`e6512e2`](https://github.com/byron/treediff-rs/commit/e6512e2c5e820bcd8b577bcbf69a20a5ceecc0e9))
- Added doc link to Readme ([`d84c44f`](https://github.com/byron/treediff-rs/commit/d84c44f7c0794a513a43b57e9ddf613f13a9cde8))
## v1.0.0 (2017-02-05)
Initial release.
### Commit Statistics
- 74 commits contributed to the release over the course of 23 calendar days.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Changed version to v1.0.0 ([`958a1f3`](https://github.com/byron/treediff-rs/commit/958a1f344e4117573377e0be9b0c665eba5d2034))
- Added all remaining docs ([`f17d671`](https://github.com/byron/treediff-rs/commit/f17d671b106b119c0118919c3e03754cf2524f21))
- Improved crate structure ([`5d0c76e`](https://github.com/byron/treediff-rs/commit/5d0c76ed5af54ed5b2ac5fd5a76ddbb499f1c0d8))
- Added even more docs/structural changes ([`b463311`](https://github.com/byron/treediff-rs/commit/b463311ce49bec69d32ea31dc841fcd71b3083c8))
- Improved module layout ([`367aaf4`](https://github.com/byron/treediff-rs/commit/367aaf4178ac6c161e4403f0507499f10f444c48))
- Added docs for main traits ([`2d6a8a8`](https://github.com/byron/treediff-rs/commit/2d6a8a8b84b7180b22f70fff3f815f688d1f03db))
- Removed unnecessary options in API ([`a370969`](https://github.com/byron/treediff-rs/commit/a370969dc958467b4be432681c3cf34aece14150))
- Added some more docs ([`ea88d65`](https://github.com/byron/treediff-rs/commit/ea88d651ef1343e30f1bb7a561e23ffacbe8e103))
- Added support for value removal on conflict ([`1195299`](https://github.com/byron/treediff-rs/commit/1195299f46321f7f84e5f618232383ca95a2e8d8))
- Added some crate docs ([`17fd836`](https://github.com/byron/treediff-rs/commit/17fd836d45f6f38c400994d0912b4a1a248b89f4))
- Improved project structure ([`5abc89d`](https://github.com/byron/treediff-rs/commit/5abc89d1349b79f0a20bff26fd5ae9c761450fda))
- Improved suite definitions ([`96d3b98`](https://github.com/byron/treediff-rs/commit/96d3b986548ffeb49d118cfefb4761b9aee96f8a))
- Added Merge support for serde-json ([`f932d4a`](https://github.com/byron/treediff-rs/commit/f932d4aa58bf8e32303b2188156f635cee2ee3e8))
- Improved API to support arbitrary modifications when merging ([`038256d`](https://github.com/byron/treediff-rs/commit/038256d62bc9999524c96b0d6da7a5122f70a8f3))
- Improved API by using Cow only when needed ([`773cd1b`](https://github.com/byron/treediff-rs/commit/773cd1b6cf07ee5a8aa828b505126874a0d977e6))
- Added support for deletion handler ([`a298c50`](https://github.com/byron/treediff-rs/commit/a298c506bff6647ec9aae65ac7f38042c31e6e32))
- Added test to verify conflict resolver. ([`46f766a`](https://github.com/byron/treediff-rs/commit/46f766a82407027143e55fabe473e77fbadeb5ee))
- Improved delegate clarity and capability of resolve() ([`d4eae6a`](https://github.com/byron/treediff-rs/commit/d4eae6a8154f6c189bac99cacfc4b5258275f633))
- Improved delegate interface consistency ([`1bcd40a`](https://github.com/byron/treediff-rs/commit/1bcd40a03baf942460df22f504aded5e69f0a0f5))
- Added groundwork for resolving conflicts ([`5630e87`](https://github.com/byron/treediff-rs/commit/5630e87c6d9f18f1f4b720e452aa234b6a0c3f59))
- Added generalized suite for merge tests ([`d146dba`](https://github.com/byron/treediff-rs/commit/d146dba4de3b66b552c9e8f0b59000776768b88f))
- Improved json value tests ([`fa1bf24`](https://github.com/byron/treediff-rs/commit/fa1bf241eded74b5a651276e7d8b9c776aeac43e))
- Added diff support for serde_json Value ([`cf1934a`](https://github.com/byron/treediff-rs/commit/cf1934a31fa05a86c750eae9ad51fe8732aa28d6))
- Added json value suite ([`1070cd4`](https://github.com/byron/treediff-rs/commit/1070cd40611ac7ad0e79beab5bb94c0e8e7551ee))
- Changed structure in preparation for serde ([`ef34105`](https://github.com/byron/treediff-rs/commit/ef34105cb3a0e700fb908c7eed07e3d9dce17190))
- Added remove_key support for json ([`0b12455`](https://github.com/byron/treediff-rs/commit/0b12455afd7aeb828133d8258e872631e5200e88))
- Changed license to MIT/Apache2 ([`b734959`](https://github.com/byron/treediff-rs/commit/b734959e42e9ea3801d11e3f695c6f7bc2edbf5a))
- Added handling for merging arrays ([`3749007`](https://github.com/byron/treediff-rs/commit/374900700ee05957d0b5b975c7253d128adc22db))
- Improved object setter code ([`c141b92`](https://github.com/byron/treediff-rs/commit/c141b92f053dfad09a023ee74a301fcc97d89d6b))
- Improved mergeable trait to not degenerate information ([`d448e7c`](https://github.com/byron/treediff-rs/commit/d448e7c6bc3d7c40259e3eee4522e47dbe6cb40d))
- Added key removal and modification for merge ([`d19b005`](https://github.com/byron/treediff-rs/commit/d19b005b0bc7770dae3a4c5c2fc679dfff44f93e))
- Added added-key tests and impl ([`52cb2b6`](https://github.com/byron/treediff-rs/commit/52cb2b6fe2fa8fcb9dd2fbd76158cbbb042e6cfb))
- Added a few tests to assert Mergeable.set() ([`e1d2c14`](https://github.com/byron/treediff-rs/commit/e1d2c14f3aaf329b8426b4513d11524a83fd5634))
- Added merge infrastructure ([`4347535`](https://github.com/byron/treediff-rs/commit/4347535a962ba16b280f265b5dc23bd423b47541))
- Improved key ownership ([`627ba19`](https://github.com/byron/treediff-rs/commit/627ba19d5e6d38dea75b72e59fbcc4613044817f))
- Added full key support ([`843d18b`](https://github.com/byron/treediff-rs/commit/843d18bd64daaa4637b254e25e2d70fa5903d17d))
- Added preliminary key support ([`70101cc`](https://github.com/byron/treediff-rs/commit/70101ccd3a9fdd81d3d70b39b1e5a4efaa0ad025))
- Added handling for scalar/object comparisons ([`434b533`](https://github.com/byron/treediff-rs/commit/434b5332790625973762ea289524efac513b5c42))
- Added implementation for nested object handling ([`86fbe0a`](https://github.com/byron/treediff-rs/commit/86fbe0a9951885a6ea78b21353113bda3db34d3a))
- Added key addition and removal ([`41abd1e`](https://github.com/byron/treediff-rs/commit/41abd1e6452044ef8d1b75af0c2f861014b3c7ca))
- Fixed tests ([`e7905a8`](https://github.com/byron/treediff-rs/commit/e7905a8a52a5e8b5cb68fc8e0e9f0007b69310a2))
- Improved type definition ([`1694109`](https://github.com/byron/treediff-rs/commit/16941091bd629afb7186af3cd08928eaf1e2e800))
- Revert "Added futile attempt to workaround type issue" ([`420e19c`](https://github.com/byron/treediff-rs/commit/420e19c2af2e31a3724c2caef790303d5f66cbbb))
- Added futile attempt to workaround type issue ([`01a4b58`](https://github.com/byron/treediff-rs/commit/01a4b58f5fed5f02ad1f55e1f12a5606d3e024b2))
- Added attempt to use a recursive type ([`a7eec83`](https://github.com/byron/treediff-rs/commit/a7eec832316e3e91bda1f07c7b6ff1cd6369db48))
- Removed std entirely ([`94b8479`](https://github.com/byron/treediff-rs/commit/94b8479b691f6a203c591cb5aa78f3b35c47613b))
- Changed diff to get closer to finding differences ([`6528fa5`](https://github.com/byron/treediff-rs/commit/6528fa57268404cf1889fb1da4a29fee924373ae))
- Improved travis to not run unnecessary tests ([`048038d`](https://github.com/byron/treediff-rs/commit/048038de591fb9a05334135d7d2d08bd1776f063))
- Added Value for HashMap ([`60ef3cf`](https://github.com/byron/treediff-rs/commit/60ef3cf804308958c4650466359c6ae337d687b0))
- Added json array value ([`b0304d1`](https://github.com/byron/treediff-rs/commit/b0304d1a959940bb17cd6a27d2d8be0104d2289d))
- Added tests for all json scalars and the json object ([`0560d81`](https://github.com/byron/treediff-rs/commit/0560d81e824f919b9ed1011892e31e636417c6a7))
- Added first scalar Json value ([`10b9858`](https://github.com/byron/treediff-rs/commit/10b98580430e0e56709367ffc8c105c1619c3228))
- Added JsonKey to abstract over usize/String ([`5ac03ce`](https://github.com/byron/treediff-rs/commit/5ac03ceaa60e4a1bf42ed1375ef16e906a7cd050))
- Added first version of json Value impl ([`837f56f`](https://github.com/byron/treediff-rs/commit/837f56f631f3c73299f3ab47d6f4fb7fd641ad65))
- Added modification of scalar values. ([`6dee766`](https://github.com/byron/treediff-rs/commit/6dee7664a89bf701a6ef78e437a4770377f113c7))
- Added utils module ([`42e7c3c`](https://github.com/byron/treediff-rs/commit/42e7c3c3956d2ef33f4e9805487cf71185557f12))
- Improved Delegate to support references ([`3e31491`](https://github.com/byron/treediff-rs/commit/3e314917f309d70c4f28859f172c92458c2efa30))
- Improved ChangeType to contain values ([`9c5904f`](https://github.com/byron/treediff-rs/commit/9c5904f86bc34739ee7efc9b773418eebee75a89))
- Added first stub of diff function ([`01d388b`](https://github.com/byron/treediff-rs/commit/01d388b34aaaff120823e9cb005b4c07f62be386))
- Removed with-std feature ([`d14deb4`](https://github.com/byron/treediff-rs/commit/d14deb49937fdb4ae4284fa0cf82910bad8daea3))
- Fixed trait type signature to use iterator ([`ca6ea4e`](https://github.com/byron/treediff-rs/commit/ca6ea4e3a11c232b06ed11466246dc82fa2faf59))
- Improved trait signature ([`569c930`](https://github.com/byron/treediff-rs/commit/569c9306028ddebad4ae151f65d53b5c9331bf41))
- Changed trait to just copy everything ([`9f8203e`](https://github.com/byron/treediff-rs/commit/9f8203ebee60114d18c541bb9cf3f5061e0a134b))
- Revert "Changed trait to support hacky polymorphism" ([`eb019cc`](https://github.com/byron/treediff-rs/commit/eb019cc2cb818aec67911e1d7c7c1f11d484be08))
- Changed trait to support hacky polymorphism ([`e544f55`](https://github.com/byron/treediff-rs/commit/e544f551aa50149574b3d319057cfe2c317bcb87))
- Improved definition of trait implementation ([`4bb8b7d`](https://github.com/byron/treediff-rs/commit/4bb8b7d51b5116d43567121e611c56d663cdc252))
- Improved trait lifetime handling ([`8107a4c`](https://github.com/byron/treediff-rs/commit/8107a4ce13b20b36738e4a7e30f054c092a3c152))
- Added simplified non-working items() method ([`e618706`](https://github.com/byron/treediff-rs/commit/e618706859a519d5fec8d82d7b480141c6ca0466))
- Improved trait by simplifying it ([`c274604`](https://github.com/byron/treediff-rs/commit/c27460407aaafe97dff664a0dcf4ff411843e2cc))
- Added attempt to create an iterator based items() method ([`edb547e`](https://github.com/byron/treediff-rs/commit/edb547e2aa5ebc0883bb44a680aac8dd3eeadb60))
- Improved Value trait ([`26ff8d4`](https://github.com/byron/treediff-rs/commit/26ff8d445c4cd01de1aafcd8d8af654bdf96811c))
- Added first impl of Value Trait for String ([`1822a45`](https://github.com/byron/treediff-rs/commit/1822a451a39321c2607b627de8859790a5ec41ab))
- Added git-journal support ([`15e670a`](https://github.com/byron/treediff-rs/commit/15e670aca7ceb56de550faa00f775af14c4a7135))
- Initial commit ([`83f2154`](https://github.com/byron/treediff-rs/commit/83f215477f57a65cbd41faaec12b82f640960967))
treediff-5.0.0/Cargo.toml 0000644 00000002707 00000000001 0010632 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "treediff"
version = "5.0.0"
authors = ["Sebastian Thiel "]
include = [
"src/**/*",
"LICENSE-*",
"README.md",
"CHANGELOG.md",
]
description = "Find the difference between arbitrary data structures"
documentation = "https://docs.rs/treediff"
readme = "README.md"
keywords = [
"diff",
"structure",
"tree",
"arbitrary",
"general",
]
categories = ["algorithms"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Byron/treediff-rs"
[dependencies.rustc-serialize]
version = "0.3.24"
optional = true
[dependencies.serde_json]
version = "1.0.45"
optional = true
[dependencies.serde_yaml]
version = "0.9"
optional = true
[dependencies.yaml-rust]
version = "0.8"
optional = true
package = "yaml-rust2"
[dev-dependencies.serde]
version = "1.0"
features = ["derive"]
[features]
with-rustc-serialize = ["rustc-serialize"]
with-serde-json = ["serde_json"]
with-serde-yaml = ["serde_yaml"]
with-yaml-rust = ["yaml-rust"]
treediff-5.0.0/Cargo.toml.orig 0000644 0000000 0000000 00000001666 10461020230 0014316 0 ustar 0000000 0000000 [package]
authors = ["Sebastian Thiel "]
description = "Find the difference between arbitrary data structures"
documentation = "https://docs.rs/treediff"
keywords = ["diff", "structure", "tree", "arbitrary", "general"]
categories = ["algorithms"]
license = "MIT/Apache-2.0"
name = "treediff"
readme = "README.md"
repository = "https://github.com/Byron/treediff-rs"
edition = "2018"
version = "5.0.0"
include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"]
[dependencies]
rustc-serialize = {version = "0.3.24", optional = true}
serde_json = {version = "1.0.45", optional = true}
serde_yaml = {version = "0.9", optional = true}
yaml-rust = {package = "yaml-rust2", version = "0.8", optional = true}
[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
[features]
with-rustc-serialize = ["rustc-serialize"]
with-serde-json = ["serde_json"]
with-serde-yaml = ["serde_yaml"]
with-yaml-rust = ["yaml-rust"]
treediff-5.0.0/LICENSE-APACHE 0000644 0000000 0000000 00000025137 10461020230 0013352 0 ustar 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
treediff-5.0.0/LICENSE-MIT 0000644 0000000 0000000 00000002041 10461020230 0013047 0 ustar 0000000 0000000 Copyright (c) 2016 Alex Crichton
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
treediff-5.0.0/README.md 0000644 0000000 0000000 00000000634 10461020230 0012700 0 ustar 0000000 0000000 
[](https://crates.io/crates/treediff)
A library to compare arbitrary structured data of the same type, efficiently.
Please see the [documentation](https://docs.rs/treediff/*) for more details.
# Usage
Add this to your Cargo.toml
```toml
[dependencies]
treediff = "4"
```
treediff-5.0.0/src/diff.rs 0000644 0000000 0000000 00000005164 10461020230 0013471 0 ustar 0000000 0000000 use crate::traitdef::{Delegate, Value};
use std::{cmp::Ordering, collections::BTreeSet};
/// A generic diff algorithm suitable for `Value` types as seen in serialization/deserialization
/// libraries.
///
/// Such types can represent any tree-like data structure, which will be traversed to find
/// *additions*, *removals*, *modifications* and even portions that did not change at all.
///
/// # Parameters
/// * `l` - the left Value
/// * `r` - the right Value
/// * `d` - a `Delegate` to receive information about changes between `l` and `r`
pub fn diff<'a, V, D>(l: &'a V, r: &'a V, d: &mut D)
where
V: Value- ,
V::Key: Ord + Clone,
D: Delegate<'a, V::Key, V>,
{
match (l.items(), r.items()) {
// two scalars, equal
(None, None) if l == r => d.unchanged(l),
// two scalars, different
(None, None) => d.modified(l, r),
// two objects, equal
(Some(_), Some(_)) if l == r => d.unchanged(l),
// object and scalar
(Some(_), None) | (None, Some(_)) => d.modified(l, r),
// two objects, different
(Some(li), Some(ri)) => {
let mut sl: BTreeSet> = BTreeSet::new();
sl.extend(li.map(Into::into));
let mut sr: BTreeSet> = BTreeSet::new();
sr.extend(ri.map(Into::into));
for k in sr.intersection(&sl) {
let v1 = sl.get(k).expect("intersection to work");
let v2 = sr.get(k).expect("intersection to work");
d.push(&k.0);
diff(v1.1, v2.1, d);
d.pop();
}
for k in sr.difference(&sl) {
d.added(&k.0, sr.get(k).expect("difference to work").1);
}
for k in sl.difference(&sr) {
d.removed(&k.0, sl.get(k).expect("difference to work").1);
}
}
}
}
struct OrdByKey<'a, K, V: 'a>(pub K, pub &'a V);
impl<'a, K, V> From<(K, &'a V)> for OrdByKey<'a, K, V> {
fn from(src: (K, &'a V)) -> Self {
OrdByKey(src.0, src.1)
}
}
impl<'a, K, V> Eq for OrdByKey<'a, K, V> where K: Eq + PartialOrd {}
impl<'a, K, V> PartialEq for OrdByKey<'a, K, V>
where
K: PartialOrd,
{
fn eq(&self, other: &OrdByKey<'a, K, V>) -> bool {
self.0.eq(&other.0)
}
}
impl<'a, K, V> PartialOrd for OrdByKey<'a, K, V>
where
K: PartialOrd,
{
fn partial_cmp(&self, other: &OrdByKey<'a, K, V>) -> Option {
self.0.partial_cmp(&other.0)
}
}
impl<'a, K, V> Ord for OrdByKey<'a, K, V>
where
K: Ord,
{
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}
}
treediff-5.0.0/src/lib.rs 0000644 0000000 0000000 00000002111 10461020230 0013314 0 ustar 0000000 0000000 //! **See what's different in arbitrary data structures**.
//!
//! The main [`diff`](`diff::diff`) algorithm.
//! we implement here is less than a screen full of lines, yet it enables a vast amount of
//! applications.
//! It can work with all values implementing the `Value` trait.
//!
//! On top of it there is a [merge][`tools::Merger`] implementation, which can be used to aggregate changes
//! into a target value. It works with `Value`s which implement the `Mutable` trait.
//!
//! # Usage
//! Please have a look at the tests for [diff][diff-tests] and [merge][merge-tests].
//!
//! Also note that you will have to choose the features to build the library with in order to
//! get trait implementations for `Value` types of common libraries,
//! i.e. `cargo build --features=with-serde-json`.
//!
//! [diff-tests]: https://github.com/Byron/treediff-rs/blob/master/tests/diff.rs
//! [merge-tests]: https://github.com/Byron/treediff-rs/blob/master/tests/merge.rs
#![deny(missing_docs, unsafe_code)]
mod diff;
pub mod tools;
mod traitdef;
pub mod value;
pub use diff::*;
pub use traitdef::*;
treediff-5.0.0/src/tools/merge.rs 0000644 0000000 0000000 00000012241 10461020230 0015012 0 ustar 0000000 0000000 use crate::traitdef::{Delegate, Mutable};
use std::{borrow::BorrowMut, borrow::Cow, fmt::Display, marker::PhantomData};
/// A `Delegate` which applies differences to a target object.
///
/// It wraps the target object and applies all calls by the `diff`
/// algorithm to it, which changes it in some way.
///
/// Custom resolver functions can be provided to arbitrarily alter
/// the way the merge is performed. This allows you, for example, to
/// keep your own meta-data, or to implement custom conflict resolutions.
///
/// # Examples
/// Please see the [tests][tests] for usage examples.
///
/// [tests]: https://github.com/Byron/treediff-rs/blob/master/tests/merge.rs#L22
pub struct Merger {
cursor: Vec,
inner: V,
filter: BF,
_d: PhantomData,
}
fn appended(keys: &[K], k: Option<&K>) -> Vec
where
K: Clone,
{
let mut keys = Vec::from(keys);
if let Some(k) = k {
keys.push(k.clone());
}
keys
}
/// A filter to manipulate calls to be made to `Value`s implementing the `Mutable` trait in calls
/// made by the `Merger` `Delegate`.
///
/// This allows you to control the exact way merge operations are performed independently of the
/// type implementing the `Value` trait, which usually is not under your control.
pub trait MutableFilter {
/// Called during `Delegate::modified(...)`, returns `None` to cause the Value at the `keys` to
/// be removed, or any Value to be set in its place.
///
/// `old` is the previous value at the given `keys` path, and `new` is the one now at its place.
/// `_target` provides access to the target of the merge operation.
fn resolve_conflict<'a, K: Clone + Display, V: Clone>(
&mut self,
_keys: &[K],
_old: &'a V,
new: &'a V,
_target: &mut V,
) -> Option> {
Some(Cow::Borrowed(new))
}
/// Called during `Delegate::removed(...)`, returns `None` to allow the Value at the `keys` path
/// to be removed, or any Value to be set in its place instead.
///
/// `removed` is the Value which is to be removed.
/// `_target` provides access to the target of the merge operation.
fn resolve_removal<'a, K: Clone + Display, V: Clone>(
&mut self,
_keys: &[K],
_removed: &'a V,
_target: &mut V,
) -> Option> {
None
}
}
/// The default implementation used when when creating a new `Merger` from any `Value` type.
///
/// If you want to choose your own filter, use `Merger::with_filter(...)` instead.
pub struct DefaultMutableFilter;
impl MutableFilter for DefaultMutableFilter {}
impl<'a, K, V, F, BF> Delegate<'a, K, V> for Merger
where
V: Mutable + Clone + 'a,
K: Clone + Display,
F: MutableFilter,
BF: BorrowMut,
{
fn push(&mut self, k: &K) {
self.cursor.push(k.clone());
}
fn pop(&mut self) {
self.cursor.pop();
}
fn removed<'b>(&mut self, k: &'b K, v: &'a V) {
let keys = appended(&self.cursor, Some(k));
match self
.filter
.borrow_mut()
.resolve_removal(&keys, v, &mut self.inner)
{
Some(nv) => self.inner.set(&keys, &nv),
None => self.inner.remove(&keys),
}
}
fn added<'b>(&mut self, k: &'b K, v: &'a V) {
self.inner.set(&appended(&self.cursor, Some(k)), v);
}
fn unchanged<'b>(&mut self, v: &'a V) {
self.inner.set(&self.cursor, v)
}
fn modified<'b>(&mut self, old: &'a V, new: &'a V) {
let keys = appended(&self.cursor, None);
match self
.filter
.borrow_mut()
.resolve_conflict(&keys, old, new, &mut self.inner)
{
Some(v) => self.inner.set(&keys, &v),
None => self.inner.remove(&keys),
}
}
}
impl Merger {
/// Consume the merger and return the contained target Value, which is the result of the
/// merge operation.
pub fn into_inner(self) -> V {
self.inner
}
/// Returns a mutable borrow to the `MutableFilter` instance
pub fn filter_mut(&mut self) -> &mut BF {
&mut self.filter
}
/// Returns a borrow to the `MutableFilter` instance
pub fn filter(&self) -> &BF {
&self.filter
}
}
impl AsRef for Merger {
fn as_ref(&self) -> &V {
&self.inner
}
}
impl<'a, V, BF, F> Merger
where
V: Mutable + 'a + Clone,
F: MutableFilter,
BF: BorrowMut,
{
/// Return a new Merger with the given initial value `v` and the filter `f`
pub fn with_filter(v: V, f: BF) -> Self {
Merger {
inner: v,
cursor: Vec::new(),
filter: f,
_d: PhantomData,
}
}
}
impl<'a, V> From for Merger
where
V: Mutable + 'a + Clone,
{
/// Return a new merger with the given initial value `v`, and the `DefaultMutableFilter`.
fn from(v: V) -> Self {
Merger {
inner: v,
cursor: Vec::new(),
filter: DefaultMutableFilter,
_d: PhantomData,
}
}
}
treediff-5.0.0/src/tools/mod.rs 0000644 0000000 0000000 00000000233 10461020230 0014470 0 ustar 0000000 0000000 //! Various tools to help making the `diff` algorithm useful with minimal effort.
mod merge;
mod record;
pub use self::merge::*;
pub use self::record::*;
treediff-5.0.0/src/tools/record.rs 0000644 0000000 0000000 00000004417 10461020230 0015177 0 ustar 0000000 0000000 use crate::traitdef::Delegate;
/// Identifies a type of change at a given Key path, for use with the `Recorder`.
///
/// The Key path is followed to know what happened with the Value `V` contained in the variants.
#[derive(Debug, PartialEq)]
pub enum ChangeType<'a, K, V: 'a> {
/// The Value was removed
Removed(Vec, &'a V),
/// The Value was added
Added(Vec, &'a V),
/// No change was performed to the Value
Unchanged(Vec, &'a V),
/// The first Value was modified and became the second Value
Modified(Vec, &'a V, &'a V),
}
/// A `Delegate` to record all calls made to it.
///
/// It can be useful if you don't want to implement your own custom delegate, but instead just want
/// to quickly see a flat list of all results of the `diff` run.
///
/// # Examples
/// Please see the [tests][tests] for how to use this type.
///
/// [tests]: https://github.com/Byron/treediff-rs/blob/master/tests/diff.rs#L21
#[derive(Debug, PartialEq)]
pub struct Recorder<'a, K, V: 'a> {
cursor: Vec,
/// A list of all calls the `diff` function made on us.
pub calls: Vec>,
}
impl<'a, K, V> Default for Recorder<'a, K, V> {
fn default() -> Self {
Recorder {
cursor: Vec::new(),
calls: Vec::new(),
}
}
}
fn mk(c: &[K], k: Option<&K>) -> Vec
where
K: Clone,
{
let mut c = Vec::from(c);
match k {
Some(k) => {
c.push(k.clone());
c
}
None => c,
}
}
impl<'a, K, V> Delegate<'a, K, V> for Recorder<'a, K, V>
where
K: Clone,
{
fn push(&mut self, k: &K) {
self.cursor.push(k.clone())
}
fn pop(&mut self) {
self.cursor.pop();
}
fn removed<'b>(&mut self, k: &'b K, v: &'a V) {
self.calls
.push(ChangeType::Removed(mk(&self.cursor, Some(k)), v));
}
fn added<'b>(&mut self, k: &'b K, v: &'a V) {
self.calls
.push(ChangeType::Added(mk(&self.cursor, Some(k)), v));
}
fn unchanged<'b>(&mut self, v: &'a V) {
self.calls
.push(ChangeType::Unchanged(self.cursor.clone(), v));
}
fn modified<'b>(&mut self, v1: &'a V, v2: &'a V) {
self.calls
.push(ChangeType::Modified(mk(&self.cursor, None), v1, v2));
}
}
treediff-5.0.0/src/traitdef.rs 0000644 0000000 0000000 00000004721 10461020230 0014361 0 ustar 0000000 0000000 /// Represents a scalar value or an associative array.
pub trait Value: PartialEq {
/// The Key type used to find Values in a mapping.
type Key;
/// The Value type itself.
type Item;
/// Returns `None` if this is a scalar value, and an iterator yielding (Key, Value) pairs
/// otherwise. It is entirely possible for it to yield no values though.
#[allow(clippy::type_complexity)]
fn items<'a>(&'a self) -> Option + 'a>>;
}
/// The delegate receiving callbacks by the `diff` algorithm, which compares an old to a new value.
///
/// # Type Parameters
/// * `K` is the Key's type
/// * `V` is the Value's type
///
/// Methods will be called if...
pub trait Delegate<'a, K, V> {
/// ... we recurse into the `Value` at the given `Key`.
///
/// Delegates should memoize the current Key path to be able to compute
/// the full Key path when needed.
fn push(&mut self, _k: &K) {}
/// ... we have processed all items and leave the object previously `push`ed.
fn pop(&mut self) {}
/// ... the Value `v` at the given Key `k` should be removed.
///
/// *Note* that the Key is partial, and should be used in conjunction with the recorded Keys
/// received via `push(...)`
fn removed<'b>(&mut self, _k: &'b K, _v: &'a V) {}
/// .. the Value `v` at the given Key `k` should be added.
///
/// *Note* that the Key is partial, and should be used in conjunction with the recorded Keys
/// received via `push(...)`
fn added<'b>(&mut self, _k: &'b K, _v: &'a V) {}
/// The Value `v` was not changed.
fn unchanged(&mut self, _v: &'a V) {}
/// ... the `old` Value was modified, and is now the `new` Value.
fn modified(&mut self, _old: &'a V, _new: &'a V) {}
}
/// A trait to allow changing any `Value`.
pub trait Mutable {
/// The Key type used to find Values in a mapping.
type Key;
/// The Value type itself.
type Item;
/// Set the `new` Value at the path identified by `keys`.
///
/// Intermediate container values (like HashMaps, Arrays) must be created until
/// the last Key in `keys` can be modified or inserted with `new`.
fn set(&mut self, keys: &[Self::Key], new: &Self::Item);
/// Remove the value located at the path identified by `keys`.
///
/// If the value does not exist, just return. Intermediate container values
/// must not be created.
fn remove(&mut self, keys: &[Self::Key]);
}
treediff-5.0.0/src/value/mod.rs 0000644 0000000 0000000 00000000564 10461020230 0014453 0 ustar 0000000 0000000 //! Contains all implementations of the `Value` and `Mutable` traits.
//!
//! Note that these are behind feature flags.
mod shared;
pub use self::shared::*;
#[cfg(feature = "with-rustc-serialize")]
mod rustc_json;
#[cfg(feature = "with-serde-json")]
mod serde_json;
#[cfg(feature = "with-serde-yaml")]
mod serde_yaml;
#[cfg(feature = "with-yaml-rust")]
mod yaml_rust;
treediff-5.0.0/src/value/rustc_json.rs 0000644 0000000 0000000 00000015231 10461020230 0016062 0 ustar 0000000 0000000 use super::Key;
use crate::traitdef::{Mutable, Value};
use rustc_serialize::json::{Json as RustcJson, Object};
use std::{collections::btree_map::Entry::*, mem};
impl Value for RustcJson {
type Key = Key;
type Item = RustcJson;
fn items<'a>(&'a self) -> Option + 'a>> {
match *self {
RustcJson::String(_)
| RustcJson::U64(_)
| RustcJson::I64(_)
| RustcJson::F64(_)
| RustcJson::Boolean(_)
| RustcJson::Null => None,
RustcJson::Array(ref inner) => Some(Box::new(
inner.iter().enumerate().map(|(i, v)| (Key::Index(i), v)),
)),
RustcJson::Object(ref inner) => Some(Box::new(
inner.iter().map(|(s, v)| (Key::String(s.clone()), v)),
)),
}
}
}
impl Mutable for RustcJson {
type Key = Key;
type Item = RustcJson;
fn set(&mut self, keys: &[Self::Key], v: &Self::Item) {
if keys.is_empty() {
*self = v.clone();
} else {
let mut c = self;
let last_key_index = keys.len() - 1;
let object_or_value = |index| {
if index == last_key_index {
v.clone()
} else {
RustcJson::Object(Object::new())
}
};
fn runup_array_or_value<'a>(
array: &'a mut Vec,
target_index: usize,
key_index: usize,
last_key_index: usize,
v: &RustcJson,
) -> &'a mut RustcJson {
for _ in array.len()..target_index {
array.push(RustcJson::Null);
}
let value = if key_index == last_key_index {
v.clone()
} else {
RustcJson::Null
};
if target_index == array.len() {
array.push(value);
} else {
array[target_index] = value;
}
&mut array[target_index]
};
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => match { c } {
&mut RustcJson::Object(ref mut obj) => match obj.entry(k.clone()) {
Vacant(e) => e.insert(object_or_value(i)),
Occupied(e) => {
if i == last_key_index {
*e.into_mut() = v.clone();
return;
} else {
e.into_mut()
}
}
},
c @ &mut RustcJson::String(_)
| c @ &mut RustcJson::F64(_)
| c @ &mut RustcJson::Boolean(_)
| c @ &mut RustcJson::Null
| c @ &mut RustcJson::U64(_)
| c @ &mut RustcJson::Array(_)
| c @ &mut RustcJson::I64(_) => {
drop(mem::replace(
c,
RustcJson::Object({
let mut o = Object::new();
o.insert(k.clone(), object_or_value(i));
o
}),
));
if i == last_key_index {
return;
}
match c {
RustcJson::Object(ref mut obj) => {
obj.get_mut(k).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
Key::Index(idx) => match { c } {
&mut RustcJson::Array(ref mut a) => {
runup_array_or_value(a, idx, i, last_key_index, v)
}
c @ &mut RustcJson::String(_)
| c @ &mut RustcJson::F64(_)
| c @ &mut RustcJson::Boolean(_)
| c @ &mut RustcJson::Null
| c @ &mut RustcJson::U64(_)
| c @ &mut RustcJson::Object(_)
| c @ &mut RustcJson::I64(_) => {
let mut a = Vec::new();
runup_array_or_value(&mut a, idx, i, last_key_index, v);
drop(mem::replace(c, RustcJson::Array(a)));
if i == last_key_index {
return;
}
match c {
RustcJson::Array(ref mut a) => {
a.get_mut(idx).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
}
}
}
}
fn remove(&mut self, keys: &[Self::Key]) {
let mut c = self;
let last_key_index = keys.len().checked_sub(1).expect("at least one key");
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => match { c } {
RustcJson::Object(ref mut obj) => {
if i == last_key_index {
obj.remove(k);
return;
} else {
match obj.get_mut(k) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
Key::Index(idx) => match { c } {
RustcJson::Array(ref mut a) => {
if i == last_key_index {
a.remove(idx);
return;
} else {
match a.get_mut(idx) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
}
}
}
}
treediff-5.0.0/src/value/serde_json.rs 0000644 0000000 0000000 00000014546 10461020230 0016034 0 ustar 0000000 0000000 use super::Key;
use crate::traitdef::{Mutable, Value};
use serde_json::{map, Map, Value as SerdeJson};
use std::mem;
impl Value for SerdeJson {
type Key = Key;
type Item = SerdeJson;
fn items<'a>(&'a self) -> Option + 'a>> {
match *self {
SerdeJson::String(_) | SerdeJson::Number(_) | SerdeJson::Bool(_) | SerdeJson::Null => {
None
}
SerdeJson::Array(ref inner) => Some(Box::new(
inner.iter().enumerate().map(|(i, v)| (Key::Index(i), v)),
)),
SerdeJson::Object(ref inner) => Some(Box::new(
inner.iter().map(|(s, v)| (Key::String(s.clone()), v)),
)),
}
}
}
impl Mutable for SerdeJson {
type Key = Key;
type Item = SerdeJson;
fn set(&mut self, keys: &[Self::Key], v: &Self::Item) {
if keys.is_empty() {
*self = v.clone();
} else {
let mut c = self;
let last_key_index = keys.len() - 1;
let object_or_value = |index| {
if index == last_key_index {
v.clone()
} else {
SerdeJson::Object(Map::new())
}
};
fn runup_array_or_value<'a>(
array: &'a mut Vec,
target_index: usize,
key_index: usize,
last_key_index: usize,
v: &SerdeJson,
) -> &'a mut SerdeJson {
for _ in array.len()..target_index {
array.push(SerdeJson::Null);
}
let value = if key_index == last_key_index {
v.clone()
} else {
SerdeJson::Null
};
if target_index == array.len() {
array.push(value);
} else {
array[target_index] = value;
}
&mut array[target_index]
};
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => match { c } {
&mut SerdeJson::Object(ref mut obj) => match obj.entry(k.clone()) {
map::Entry::Vacant(e) => e.insert(object_or_value(i)),
map::Entry::Occupied(e) => {
if i == last_key_index {
*e.into_mut() = v.clone();
return;
} else {
e.into_mut()
}
}
},
c @ &mut SerdeJson::String(_)
| c @ &mut SerdeJson::Number(_)
| c @ &mut SerdeJson::Bool(_)
| c @ &mut SerdeJson::Null
| c @ &mut SerdeJson::Array(_) => {
drop(mem::replace(
c,
SerdeJson::Object({
let mut o = Map::new();
o.insert(k.clone(), object_or_value(i));
o
}),
));
if i == last_key_index {
return;
}
match c {
SerdeJson::Object(ref mut obj) => {
obj.get_mut(k).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
Key::Index(idx) => match { c } {
&mut SerdeJson::Array(ref mut a) => {
runup_array_or_value(a, idx, i, last_key_index, v)
}
c @ &mut SerdeJson::String(_)
| c @ &mut SerdeJson::Number(_)
| c @ &mut SerdeJson::Bool(_)
| c @ &mut SerdeJson::Null
| c @ &mut SerdeJson::Object(_) => {
let mut a = Vec::new();
runup_array_or_value(&mut a, idx, i, last_key_index, v);
drop(mem::replace(c, SerdeJson::Array(a)));
if i == last_key_index {
return;
}
match c {
SerdeJson::Array(ref mut a) => {
a.get_mut(idx).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
}
}
}
}
fn remove(&mut self, keys: &[Self::Key]) {
let mut c = self;
let last_key_index = keys.len().checked_sub(1).expect("at least one key");
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => match { c } {
SerdeJson::Object(ref mut obj) => {
if i == last_key_index {
obj.remove(k);
return;
} else {
match obj.get_mut(k) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
Key::Index(idx) => match { c } {
SerdeJson::Array(ref mut a) => {
if i == last_key_index {
a.remove(idx);
return;
} else {
match a.get_mut(idx) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
}
}
}
}
treediff-5.0.0/src/value/serde_yaml.rs 0000644 0000000 0000000 00000016555 10461020230 0016027 0 ustar 0000000 0000000 use super::Key;
use crate::traitdef::{Mutable, Value};
use serde_yaml::{self, to_string, Mapping, Value as SerdeYaml};
use std::mem;
fn from_str(s: &str) -> SerdeYaml {
serde_yaml::from_str(s).expect("valid yaml document, we created the key via to_string")
}
impl Value for SerdeYaml {
type Key = Key;
type Item = SerdeYaml;
fn items<'a>(&'a self) -> Option + 'a>> {
match *self {
SerdeYaml::String(_)
| SerdeYaml::Number(_)
| SerdeYaml::Bool(_)
| SerdeYaml::Null
| SerdeYaml::Tagged(_) => None,
SerdeYaml::Sequence(ref inner) => Some(Box::new(
inner.iter().enumerate().map(|(i, v)| (Key::Index(i), v)),
)),
SerdeYaml::Mapping(ref inner) => Some(Box::new(inner.iter().map(|(k, v)| {
(
Key::String(
to_string(k)
.expect("yaml value to serialize into yaml correctly")
.to_owned(),
),
v,
)
}))),
}
}
}
impl Mutable for SerdeYaml {
type Key = Key;
type Item = SerdeYaml;
fn set(&mut self, keys: &[Self::Key], v: &Self::Item) {
if keys.is_empty() {
*self = v.clone();
} else {
let mut c = self;
let last_key_index = keys.len() - 1;
let object_or_value = |index| {
if index == last_key_index {
v.clone()
} else {
SerdeYaml::Mapping(Mapping::new())
}
};
fn runup_array_or_value<'a>(
array: &'a mut Vec,
target_index: usize,
key_index: usize,
last_key_index: usize,
v: &SerdeYaml,
) -> &'a mut SerdeYaml {
for _ in array.len()..target_index {
array.push(SerdeYaml::Null);
}
let value = if key_index == last_key_index {
v.clone()
} else {
SerdeYaml::Null
};
if target_index == array.len() {
array.push(value);
} else {
array[target_index] = value;
}
&mut array[target_index]
}
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => {
let k = from_str(&k);
match { c } {
&mut SerdeYaml::Mapping(ref mut obj) => {
if obj.contains_key(&k) {
let obj = obj.get_mut(&k).expect("map to work");
if i == last_key_index {
*obj = v.clone();
return;
}
obj
} else {
obj.insert(k.clone(), object_or_value(i));
obj.get_mut(&k).expect("map to work")
}
}
c @ &mut SerdeYaml::String(_)
| c @ &mut SerdeYaml::Number(_)
| c @ &mut SerdeYaml::Bool(_)
| c @ &mut SerdeYaml::Null
| c @ &mut SerdeYaml::Sequence(_)
| c @ &mut SerdeYaml::Tagged(_) => {
drop(mem::replace(
c,
SerdeYaml::Mapping({
let mut o = Mapping::new();
o.insert(k.clone(), object_or_value(i));
o
}),
));
if i == last_key_index {
return;
}
match c {
SerdeYaml::Mapping(ref mut obj) => {
obj.get_mut(&k).expect("previous insertion")
}
_ => unreachable!(),
}
}
}
}
Key::Index(idx) => match { c } {
&mut SerdeYaml::Sequence(ref mut a) => {
runup_array_or_value(a, idx, i, last_key_index, v)
}
c @ &mut SerdeYaml::String(_)
| c @ &mut SerdeYaml::Number(_)
| c @ &mut SerdeYaml::Bool(_)
| c @ &mut SerdeYaml::Null
| c @ &mut SerdeYaml::Mapping(_)
| c @ &mut SerdeYaml::Tagged(_) => {
let mut a = Vec::new();
runup_array_or_value(&mut a, idx, i, last_key_index, v);
drop(mem::replace(c, SerdeYaml::Sequence(a)));
if i == last_key_index {
return;
}
match c {
SerdeYaml::Sequence(ref mut a) => {
a.get_mut(idx).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
}
}
}
}
fn remove(&mut self, keys: &[Self::Key]) {
let mut c = self;
let last_key_index = keys.len().checked_sub(1).expect("at least one key");
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => {
let k = from_str(&k);
match { c } {
SerdeYaml::Mapping(ref mut obj) => {
if i == last_key_index {
obj.remove(&k);
return;
} else {
match obj.get_mut(&k) {
Some(json) => json,
None => return,
}
}
}
_ => return,
}
}
Key::Index(idx) => match { c } {
SerdeYaml::Sequence(ref mut a) => {
if i == last_key_index {
a.remove(idx);
return;
} else {
match a.get_mut(idx) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
}
}
}
}
treediff-5.0.0/src/value/shared.rs 0000644 0000000 0000000 00000000727 10461020230 0015143 0 ustar 0000000 0000000 use std::fmt;
/// A representation of all key types typical Value types will assume.
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum Key {
/// An array index
Index(usize),
/// A string index for mappings
String(String),
}
impl fmt::Display for Key {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Key::String(ref v) => v.fmt(f),
Key::Index(ref v) => v.fmt(f),
}
}
}
treediff-5.0.0/src/value/yaml_rust.rs 0000644 0000000 0000000 00000017022 10461020230 0015710 0 ustar 0000000 0000000 use super::Key;
use crate::traitdef::{Mutable, Value};
use std::mem;
use yaml_rust::{yaml::Hash, Yaml, YamlEmitter, YamlLoader};
fn from_str(s: &str) -> Yaml {
let mut v = YamlLoader::load_from_str(s)
.expect("valid yaml value - we serialized it beforehand after all");
assert_eq!(
v.len(),
1,
"need exactly one document - multi-document keys are just not possible"
);
v.pop().unwrap()
}
fn to_string(v: &Yaml) -> String {
let mut buf = String::new();
YamlEmitter::new(&mut buf)
.dump(v)
.expect("valid yaml value");
buf[4..].to_owned()
}
impl Value for Yaml {
type Key = Key;
type Item = Yaml;
fn items<'a>(&'a self) -> Option + 'a>> {
match *self {
Yaml::String(_)
| Yaml::Integer(_)
| Yaml::Real(_)
| Yaml::Boolean(_)
| Yaml::Null
| Yaml::Alias(_)
| Yaml::BadValue => None,
Yaml::Array(ref inner) => Some(Box::new(
inner.iter().enumerate().map(|(i, v)| (Key::Index(i), v)),
)),
Yaml::Hash(ref inner) => Some(Box::new(
inner.iter().map(|(k, v)| (Key::String(to_string(k)), v)),
)),
}
}
}
impl Mutable for Yaml {
type Key = Key;
type Item = Yaml;
fn set(&mut self, keys: &[Self::Key], v: &Self::Item) {
if keys.is_empty() {
*self = v.clone();
} else {
let mut c = self;
let last_key_index = keys.len() - 1;
let object_or_value = |index| {
if index == last_key_index {
v.clone()
} else {
Yaml::Hash(Hash::new())
}
};
fn runup_array_or_value<'a>(
array: &'a mut Vec,
target_index: usize,
key_index: usize,
last_key_index: usize,
v: &Yaml,
) -> &'a mut Yaml {
for _ in array.len()..target_index {
array.push(Yaml::Null);
}
let value = if key_index == last_key_index {
v.clone()
} else {
Yaml::Null
};
if target_index == array.len() {
array.push(value);
} else {
array[target_index] = value;
}
&mut array[target_index]
}
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => {
let k = from_str(&k);
match { c } {
&mut Yaml::Hash(ref mut obj) => {
if obj.contains_key(&k) {
let obj = obj.get_mut(&k).expect("map to work");
if i == last_key_index {
*obj = v.clone();
return;
}
obj
} else {
obj.insert(k.clone(), object_or_value(i));
obj.get_mut(&k).expect("map to work")
}
}
c @ &mut Yaml::String(_)
| c @ &mut Yaml::Integer(_)
| c @ &mut Yaml::Real(_)
| c @ &mut Yaml::Boolean(_)
| c @ &mut Yaml::Null
| c @ &mut Yaml::Alias(_)
| c @ &mut Yaml::BadValue
| c @ &mut Yaml::Array(_) => {
drop(mem::replace(
c,
Yaml::Hash({
let mut o = Hash::new();
o.insert(k.clone(), object_or_value(i));
o
}),
));
if i == last_key_index {
return;
}
match c {
Yaml::Hash(ref mut obj) => {
obj.get_mut(&k).expect("previous insertion")
}
_ => unreachable!(),
}
}
}
}
Key::Index(idx) => match { c } {
&mut Yaml::Array(ref mut a) => {
runup_array_or_value(a, idx, i, last_key_index, v)
}
c @ &mut Yaml::String(_)
| c @ &mut Yaml::Alias(_)
| c @ &mut Yaml::BadValue
| c @ &mut Yaml::Integer(_)
| c @ &mut Yaml::Real(_)
| c @ &mut Yaml::Boolean(_)
| c @ &mut Yaml::Null
| c @ &mut Yaml::Hash(_) => {
let mut a = Vec::new();
runup_array_or_value(&mut a, idx, i, last_key_index, v);
drop(mem::replace(c, Yaml::Array(a)));
if i == last_key_index {
return;
}
match c {
Yaml::Array(ref mut a) => {
a.get_mut(idx).expect("previous insertion")
}
_ => unreachable!(),
}
}
},
}
}
}
}
fn remove(&mut self, keys: &[Self::Key]) {
let mut c = self;
let last_key_index = keys.len().checked_sub(1).expect("at least one key");
for (i, k) in keys.iter().enumerate() {
c = match *k {
Key::String(ref k) => {
let k = from_str(&k);
match { c } {
Yaml::Hash(ref mut obj) => {
if i == last_key_index {
obj.remove(&k);
return;
} else {
match obj.get_mut(&k) {
Some(json) => json,
None => return,
}
}
}
_ => return,
}
}
Key::Index(idx) => match { c } {
Yaml::Array(ref mut a) => {
if i == last_key_index {
a.remove(idx);
return;
} else {
match a.get_mut(idx) {
Some(json) => json,
None => return,
}
}
}
_ => return,
},
}
}
}
}