Module std::text::semver

Semantic versioning โ€” pure Hew implementation.

Parse, inspect, compare, and match semantic version strings according to the SemVer 2.0.0 specification.

Examples

import std::text::semver;

fn main() {
    let v = semver.parse("1.2.3-beta.1");
    println(v.major());
    if v.matches(">=1.0.0") {
        println("compatible");
    }
}

Contents

Functions

Function parse

pub fn parse(s: String) -> Version

Parse a semantic version string.

Panics if the string is not a valid semantic version.

Function version_to_string

fn version_to_string(v: Version) -> String

Format a Version as its canonical string representation.

Function compare_versions

fn compare_versions(a: Version, b: Version) -> i32

Compare two versions according to SemVer 2.0 precedence rules.

Function compare_pre

fn compare_pre(a: String, b: String) -> i32

Compare two dot-separated pre-release identifier strings.

Function compare_pre_id

fn compare_pre_id(a: String, b: String) -> i32

Compare two individual pre-release identifiers (numeric or alphanumeric).

Function matches_req

fn matches_req(v: Version, req: String) -> bool

Test whether a version satisfies a comma-separated requirement string.

Function matches_single

fn matches_single(v: Version, constraint: String) -> bool

Test whether a version satisfies a single version constraint.

Types

Struct Version

A parsed semantic version.

Fields

pre_release: String
build_meta: String
maj: i32
min: i32
pat: i32

Traits

Trait VersionMethods

Methods available on a parsed Version.

Methods

fn major(self: Version) -> i64 fn minor(self: Version) -> i64 fn patch(self: Version) -> i64 fn pre(self: Version) -> String fn compare(self: Version, other: Version) -> i32 fn matches(self: Version, req: String) -> bool fn to_string(self: Version) -> String fn free(self: Version)