#semver #version #semantic #versioning

recital

Create, parse, edit, and compare semantic version numbers

3 releases (breaking)

Uses old Rust 2015

0.3.0 Feb 20, 2016
0.2.0 Feb 19, 2016
0.1.0 Feb 18, 2016

#76 in #versioning

37 downloads per month
Used in ver

MIT license

40KB
728 lines

Build Status Crates.io

Recital

Create, parse, edit, and compare semantic version numbers.

Usage

#[macro_use]
extern crate recital;

fn main() {
    let installed: Version = "1.0.0-beta".parse();
    let published: Version = "1.3.4".parse();

    if published > installed {
        println("A new version is available: {}", published);
    }
}

Please refer to the documentation for the crate.

Installation

Add it to your list of dependencies.

"recital" = "0.3.0"

License

Released under the MIT license.


lib.rs:

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);

Dependencies

~535KB
~10K SLoC