Crates.io | terraform-version |
lib.rs | terraform-version |
version | 0.4.0 |
source | src |
created_at | 2023-02-28 17:17:03.335978 |
updated_at | 2023-03-20 18:16:47.742464 |
description | Parser and match calculator for terraform version constraint syntax |
homepage | |
repository | https://gitlab.com/vigigloo/libs/terraform-version |
max_upload_size | |
id | 797273 |
size | 25,095 |
terraform-version
is a short parser and match calculator for terraform version constraint syntax.
It follows the terraform semantic constraints.
[dependencies]
terraform-version = "0.4"
Compiler support: requires rustc 1.67+
use terraform_version::{Version, VersionRequirement, NumericIdentifiers};
fn main() {
let version_req = VersionRequirement::parse("< 5.4.3, >= 1.2.3").unwrap();
let version = Version::parse("1.2.3").unwrap();
assert!(version.matches(&version_req));
let version = Version::parse("5.4.4").unwrap();
assert!(!version.matches(&version_req));
let version_req = VersionRequirement::parse("= 1.2.3-beta").unwrap();
let version = Version::parse("1.2.3-beta").unwrap();
assert!(version.matches(&version_req));
let version = Version {
numeric_identifiers: NumericIdentifiers::new(vec![1, 2, 3]),
suffix: None
};
assert!(!version.matches(&version_req));
}
terraform-version
is provided under the MIT license. See LICENSE.