{"id":20390346,"url":"https://github.com/timvisee/version-compare","last_synced_at":"2025-04-12T11:21:31.193Z","repository":{"id":47076155,"uuid":"84578924","full_name":"timvisee/version-compare","owner":"timvisee","description":":left_right_arrow: Rust library to easily compare version strings. Mirror from https://gitlab.com/timvisee/version-compare","archived":false,"fork":false,"pushed_at":"2024-03-16T11:37:32.000Z","size":285,"stargazers_count":44,"open_issues_count":6,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T06:11:13.608Z","etag":null,"topics":["comparison","crates","hacktoberfest","rust","rust-library","version"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/version-compare","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timvisee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["timvisee"],"custom":["https://timvisee.com/donate"],"patreon":"timvisee","ko_fi":"timvisee"}},"created_at":"2017-03-10T16:25:58.000Z","updated_at":"2025-02-07T10:45:03.000Z","dependencies_parsed_at":"2024-03-16T12:57:18.986Z","dependency_job_id":"f6cb88d3-1ee5-4912-b134-f588b4fc9c59","html_url":"https://github.com/timvisee/version-compare","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvisee%2Fversion-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvisee%2Fversion-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvisee%2Fversion-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvisee%2Fversion-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timvisee","download_url":"https://codeload.github.com/timvisee/version-compare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248558129,"owners_count":21124223,"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","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":["comparison","crates","hacktoberfest","rust","rust-library","version"],"created_at":"2024-11-15T03:24:27.313Z","updated_at":"2025-04-12T11:21:31.161Z","avatar_url":"https://github.com/timvisee.png","language":"Rust","funding_links":["https://github.com/sponsors/timvisee","https://timvisee.com/donate","https://patreon.com/timvisee","https://ko-fi.com/timvisee"],"categories":[],"sub_categories":[],"readme":"[![Build status on GitLab CI][gitlab-ci-master-badge]][gitlab-ci-link]\n[![Crate version][crate-version-badge]][crate-link]\n[![Documentation][docs-badge]][docs]\n[![Download statistics][crate-download-badge]][crate-link]\n[![Coverage status][coverage-badge]][coverage-link]\n[![Dependencies][dependency-badge]][crate-link]\n[![License][crate-license-badge]][crate-link]\n\n[coverage-badge]: https://gitlab.com/timvisee/version-compare/badges/master/coverage.svg\n[coverage-link]: https://coveralls.io/gitlab/timvisee/version-compare\n[crate-download-badge]: https://img.shields.io/crates/d/version-compare.svg\n[crate-license-badge]: https://img.shields.io/crates/l/version-compare.svg\n[crate-link]: https://crates.io/crates/version-compare\n[crate-version-badge]: https://img.shields.io/crates/v/version-compare.svg\n[dependency-badge]: https://img.shields.io/badge/dependencies-none!-green.svg\n[docs-badge]: https://img.shields.io/docsrs/version-compare\n[docs]: https://docs.rs/version-compare\n[gitlab-ci-link]: https://gitlab.com/timvisee/version-compare/pipelines\n[gitlab-ci-master-badge]: https://gitlab.com/timvisee/version-compare/badges/master/pipeline.svg\n\n# Rust library: version-compare\n\n\u003e Rust library to easily compare version numbers with no specific format, and test against various comparison operators.\n\nComparing version numbers is hard, especially with weird version number formats.\n\nThis library helps you to easily compare any kind of version number with no\nspecific format using a best-effort approach.\nTwo version numbers can be compared to each other to get a comparison operator\n(`\u003c`, `==`, `\u003e`), or test them against a comparison operator.\n\nAlong with version comparison, the library provides various other tools for\nworking with version numbers.\n\nInspired by PHPs [version_compare()](http://php.net/manual/en/function.version-compare.php).\n\n_Note: Still a work in progress. Configurability is currently very limited. Things will change._\n\n### Formats\n\nVersion numbers that would parse successfully include:  \n`1`, `3.10.4.1`, `1.2.alpha`, `1.2.dev.4`, ` `, ` .   -32 . 1`, `MyApp 3.2.0 / build 0932` ...\n\nSee a list of how version numbers compare [here](https://github.com/timvisee/version-compare/blob/411ed7135741ed7cf2fcf4919012fb5412dc122b/src/test.rs#L50-L103).\n\n## Example\n\nThis library is very easy to use. Here's a basic usage example:\n\n`Cargo.toml`:\n```toml\n[dependencies]\nversion-compare = \"0.2\"\n```\n\n[`example.rs`](examples/example.rs):\n```rust\nuse version_compare::{compare, compare_to, Cmp, Version};\n\nfn main() {\n    let a = \"1.2\";\n    let b = \"1.5.1\";\n\n    // The following comparison operators are used:\n    // - Cmp::Eq -\u003e Equal\n    // - Cmp::Ne -\u003e Not equal\n    // - Cmp::Lt -\u003e Less than\n    // - Cmp::Le -\u003e Less than or equal\n    // - Cmp::Ge -\u003e Greater than or equal\n    // - Cmp::Gt -\u003e Greater than\n\n    // Easily compare version strings\n    assert_eq!(compare(a, b), Ok(Cmp::Lt));\n    assert_eq!(compare_to(a, b, Cmp::Le), Ok(true));\n    assert_eq!(compare_to(a, b, Cmp::Gt), Ok(false));\n\n    // Parse and wrap version strings as a Version\n    let a = Version::from(a).unwrap();\n    let b = Version::from(b).unwrap();\n\n    // The Version can easily be compared with\n    assert_eq!(a \u003c b, true);\n    assert_eq!(a \u003c= b, true);\n    assert_eq!(a \u003e b, false);\n    assert_eq!(a != b, true);\n    assert_eq!(a.compare(\u0026b), Cmp::Lt);\n    assert_eq!(a.compare_to(\u0026b, Cmp::Lt), true);\n\n    // Or match the comparison operators\n    match a.compare(b) {\n        Cmp::Lt =\u003e println!(\"Version a is less than b\"),\n        Cmp::Eq =\u003e println!(\"Version a is equal to b\"),\n        Cmp::Gt =\u003e println!(\"Version a is greater than b\"),\n        _ =\u003e unreachable!(),\n    }\n}\n```\n\nSee the [`examples`](examples) directory for more.\n\n## Features\n\n* Compare version numbers, get: `\u003c`, `==`, `\u003e`\n* Compare against a comparison operator\n  (`\u003c`, `\u003c=`, `==`, `!=`, `\u003e=`, `\u003e`)\n* Parse complex and unspecified formats\n* Static, standalone methods to easily compare version strings in a single line\n  of code\n\n#### Future ideas\n\n* Version ranges\n* Support for [npm-style](https://semver.npmjs.com/) operators (e.g. `^1.0` or `~1.0`)\n* Manifest: extend `Manifest` for to support a wide set of constraints\n* Building blocks for building your own specific version number parser\n* Batch comparisons\n\n#### Semver\n\nVersion numbers using the [semver](http://semver.org/) format are compared\ncorrectly with no additional configuration.\n\nIf your version number strings follow this exact format you may be better off\nusing the [`semver`](https://crates.io/crates/semver) crate for more format\nspecific features.\n\nIf that isn't certain however, `version-compare` makes comparing a breeze.\n\n## Builds\n\nThis library is automatically build and tested every day and for each commit using CI services.\n\nSee the current status here: https://gitlab.com/timvisee/version-compare/-/pipelines\n\n## License\n\nThis project is released under the MIT license. Check out the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimvisee%2Fversion-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimvisee%2Fversion-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimvisee%2Fversion-compare/lists"}