Module semver_parser::range[][src]

Version range and requirements data and functions (used for version comparison).

This module contains Predicate struct which holds data for comparison version::Version structs: VersionReq struct as a collection of Predicates, functions for parsing those structs and some helper data structures and functions.

Examples

Parsing version range and matching it with concrete version:

use semver_parser::range;
use semver_parser::version;

let r = range::parse("1.0.0")?;

assert_eq!(range::Predicate {
        op: range::Op::Compatible,
        major: 1,
        minor: Some(0),
        patch: Some(0),
        pre: Vec::new(),
    },
    r.predicates[0]
);

let m = version::parse("1.0.0")?;
for p in &r.predicates {
    match p.op {
        range::Op::Compatible => {
            assert_eq!(p.major, m.major);
        }
        _ => {
            unimplemented!();
        }
    }
}

Structs

Predicate

Struct representing a version comparison predicate.

VersionReq

Struct holding collection of version requirements.

Enums

Op

Enum representing operation in Predicate.

WildcardVersion

Enum representing a * version part.

Functions

parse

Function for parsing VersionReq from string.

parse_predicate

Function parsing Predicate from string.