| Crates.io | version-lp |
| lib.rs | version-lp |
| version | 0.2.1 |
| created_at | 2018-11-19 04:24:11.402056+00 |
| updated_at | 2018-12-17 01:03:54.66926+00 |
| description | a version struct library for use with version comparing, and wildcard resolving |
| homepage | |
| repository | https://github.com/snsvrno/version-lp-rs |
| max_upload_size | |
| id | 97541 |
| size | 23,392 |
A rust library for dealing with versions designed to be used with lovepack tools.
Contains a custom version Struct that is based on the Semantic Versioning System. Only supports the a.b.c format, but with any number of points, i.e. a.b, a.b.c.d are also valid versions. Also has support for wildcards when compairing Versions.
let wild_version = Version::from_str("2.*.*");
Version::from_string("2.3.4").unwrap().is_compatible_with(&wild_version) // will return true
And standard comparions can be used.
let ver_a = Version::from_str("2.1.4");
let ver_b = Version::from_str("2.2.3");
let ver_c = Version::from_str("2.1.4");
ver_a < ver_b // true
ver_a == ver_c // true
You can also get the latest available version from a list.
let versions : Vec<Version> = vec![
Version::from_str("1.0.0").unwrap(),
Version::from_str("1.0.1").unwrap(),
Version::from_str("1.1.0").unwrap(),
Version::from_str("1.0.2").unwrap()
];
let requirement = Version::from_str("1").unwrap();
let version = requirement.latest_compatible_version(&versions); // would be Version (1.1.0)
is_compatible_with function.1.2 will be compatible with 1.2.3Currently the only wildcard supported is *. But ^ can be achieved by using short versions: 1.2 would match with 1.2.1 to 1.2.100 and would return the latest version in a list using ::latest_compatible_version.