https://github.com/snsvrno/version-lp-rs
Version struct for use in Rust, designed for Lovepack.
https://github.com/snsvrno/version-lp-rs
library lovepack
Last synced: 6 months ago
JSON representation
Version struct for use in Rust, designed for Lovepack.
- Host: GitHub
- URL: https://github.com/snsvrno/version-lp-rs
- Owner: snsvrno
- License: mit
- Created: 2018-03-12T11:56:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T16:12:19.000Z (about 6 years ago)
- Last Synced: 2025-10-01T08:36:27.790Z (9 months ago)
- Topics: library, lovepack
- Language: Rust
- Homepage: https://crates.io/crates/version-lp
- Size: 26.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# version-lp-rs
A rust library for dealing with versions designed to be used with lovepack tools.
## Overview
Contains a custom version ***Struct*** that is based on the [Semantic Versioning System](https://semver.org/). 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`.
```rust
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.
```rust
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.
```rust
let versions : Vec = 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)
```
## Notes for Success
- You cannot compare against patterns, patterns can only be checked using the `is_compatible_with` function.
- Wildcards will be assumed when compairing different length version numbers. `1.2` will be compatible with `1.2.3`
## Pattern Matching
Currently 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`.