{"id":26728816,"url":"https://github.com/slashdotted/yavomrs","last_synced_at":"2025-08-01T11:15:15.571Z","repository":{"id":62444780,"uuid":"473636102","full_name":"slashdotted/yavomrs","owner":"slashdotted","description":"Yet Another Variation of Myers for generic containers (for example std::vec::Vec) ","archived":false,"fork":false,"pushed_at":"2022-06-21T14:04:46.000Z","size":5862,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T11:12:23.284Z","etag":null,"topics":["diff","myers","myers-algorithm","rust","rust-crate","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slashdotted.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-24T14:15:40.000Z","updated_at":"2023-05-05T16:57:30.000Z","dependencies_parsed_at":"2022-11-01T23:33:38.254Z","dependency_job_id":null,"html_url":"https://github.com/slashdotted/yavomrs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/slashdotted/yavomrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fyavomrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fyavomrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fyavomrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fyavomrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slashdotted","download_url":"https://codeload.github.com/slashdotted/yavomrs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fyavomrs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267929218,"owners_count":24167447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diff","myers","myers-algorithm","rust","rust-crate","rust-library"],"created_at":"2025-03-27T22:36:43.700Z","updated_at":"2025-08-01T11:15:15.552Z","avatar_url":"https://github.com/slashdotted.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yavom\nYet Another Variation of Myers for generic containers (for example std::Vec)\n\nThis is an implementation of a quasi-Myers algorithm to determine the differences between two generic containers. Its usage is quite simple, for example:\n\n```rust\nlet mut a: Vec\u003cString\u003e = vec![\"A\", \"W\", \"E\", \"S\", \"O\", \"M\", \"O\"]\n            .iter()\n            .map(|s| s.to_string())\n            .collect();\nlet b: Vec\u003cString\u003e = vec![\"S\", \"T\", \"R\", \"A\", \"N\", \"G\", \"E\", \"S\", \"O\", \"M\", \"O\"]\n            .iter()\n            .map(|s| s.to_string())\n            .collect();\n\n// Create the diff (vector of moves)\nlet moves = crate::yavom::myers(\u0026a, \u0026b);\n```\nThe return value *moves* is a vector of *Move* objects. You can apply moves to the array as follows:\n```rust\nmoves.iter().for_each(|m| { crate::yavom::apply_move(m, \u0026mut a); });\n// now a's contents are the same as b's\n```\nYou can serialize / deserialize *Move* objects as you deem necessary. To do so please consider the following definitions (found in *diff.h*):\n```rust\npub enum OP {\n    INSERT,\n    DELETE,\n    _DELETE,\n}\n\npub struct Point(pub i64, pub i64);\n\npub struct Move\u003cK\u003e(pub OP, pub Point, pub Point, pub Option\u003cVec\u003cK\u003e\u003e);\n\n```\nThe *Vec\u003cK\u003e* field stores the values to be inserted. For example:\n```rust\n let ops = myers_unfilled(\u0026a, \u0026b);\n let mut patch = vec![];\n for o in ops {\n      let Move(op, s, t, _) = o;\n      match op {\n          yavomrs::yavom::OP::INSERT =\u003e {\n              let from = s.1 as usize;\n              let to = (s.1 + count) as usize;\n              let insert_position = s.1;\n              let values = \u0026new[from..to];\n              // TODO Serialize INSERT of values at insert_position\n          }\n          yavomrs::yavom::OP::DELETE =\u003e {\n              let count = t.0 - s.0;\n              let delete_position = s.1;\n              // TODO Serialize DELETE of count values starting from delete_position\n          }\n          yavomrs::yavom::OP::_DELETE =\u003e {\n              let Point(count, start) = s;\n              // TODO Serialize DELETE of count values starting from start\n          }\n      }\n  }\n  \n```\nIf you are interested in knowning how many moves will be necessary but do not want to generate complete moves (with complete insert data), you can\nuse the *myers_unfilled* function:\n```rust\nlet mut moves = crate::yavom::myers_unfilled(\u0026a, \u0026b);\neprintln!(\"{} moves\", moves.len());\n``` \nSubsequently you can fill the insertion data:\n```rust\ncrate::yavom::myers_fill(\u0026b, \u0026mut moves);\n```\n\n## Credits \u0026 License\nThis code is Copyright (C) 2022 Amos Brocco (contact@amosbrocco.ch)\n\nBSD 3-Clause License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotted%2Fyavomrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslashdotted%2Fyavomrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotted%2Fyavomrs/lists"}