Crate recital [−] [src]
Create, parse, edit, and compare semantic version numbers.
This library provides you with nearly everything you need to make use of version numbers that are compatible with version 2.0.0 of the Semantic Versioning specification. The specification is required reading if you do not already know the rules and requirements for a semantic version number. The specification is pretty small, so it shouldn't take too long!
Specification
You can find the specification at semver.org.
Usage
The library tries to make working with semantic version numbers as simple as possible. As a result of this effort, there is a lot of things you can do with these numbers. This usage guide will cover high level stuff, so you may want to read the documentation for the structures and traits that are included for more advanced information.
#[macro_use] extern crate recital; use recital::prelude::*;
Creating
let version = version!(1, 2, 3, vec![id!("abc"), id!(456)], vec![id!("def"), id!(789)]);
Parsing
let version: Version = "1.2.3-abc.456+def.789".parse().unwrap();
Modifying
// `0.0.0` let mut version = Version::new(); // `1.2.3` version.major = 1; version.minor = 2; version.patch = 3; // `1.2.3-abc.456+def.789` version.pre.push(id!("abc")); version.pre.push(id!(456)); version.build.push(id!("def")); version.build.push(id!(789)); // `2.1.1` version.increment_major(); version.increment_minor(); version.increment_patch();
Comparing
You can compare versions like you would any number.
let a: Version = "1.2.3-alpha".parse().unwrap(); let b: Version = "1.2.3".parse().unwrap(); assert!(a < b); assert!(!(a > b)); assert!(a != b);
Modules
prelude |
Re-exports submodules for glob imports. |
resolve |
Creates and applies constraints for semantic version numbers. |
version |
Creates, parses, and manages semantic version numbers. |
Macros
constraints |
Creates a new set of constraints. |
id |
Creates a new identifier. |
version |
Creates a new version number. |