SemanticVersion structv0.1.0

Source
A semantic version, as its three numeric core components.
pub struct SemanticVersion {
    pub major: uint;
    pub minor: uint;
    pub patch: uint;
}

Carries the core only: a pre-release tag or build metadata is not represented, so two versions differing only in those compare equal. Copy, owns nothing, and allocates nothing. Ordered by precedence, major component first, as semantic versioning defines it.

Fields

NameTypeDescription
majoruintThe major component, which changes when compatibility does.
minoruintThe minor component.
patchuintThe patch component.

Constructors

SemanticVersion

pub func SemanticVersion(
    major: uint,
    minor: uint,
    patch: uint
) -> SemanticVersion

Constructs a version with the given components. All three are read by value; the version is returned by copy and borrows nothing. Cannot fail: every triple of components is a version. Runs in constant time and allocates nothing.

NameTypeDescription
majoruintthe major version
minoruintthe minor version
patchuintthe patch version

Returns: the version

Source

Methods

Compare

pub func Compare(
    self: &SemanticVersion,
    other: SemanticVersion
) -> int

Compares precedence with other. self is borrowed and other is read by value. Returns a negative value when self precedes other, zero when the two have the same precedence, and a positive value when self follows it. Components are compared major first, and the first difference decides. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: how this value orders against other

Source

IsEqualTo

pub func IsEqualTo(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Whether the two versions have the same precedence. self is borrowed and other is read by value. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether the two versions are the same

Source

IsLessThan

pub func IsLessThan(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Whether this version precedes other. self is borrowed and other is read by value. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this version is older

Source

IsAtMost

pub func IsAtMost(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Whether this version precedes other or matches it. self is borrowed and other is read by value. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this version is the same or older

Source

IsGreaterThan

pub func IsGreaterThan(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Whether this version follows other. self is borrowed and other is read by value. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this version is newer

Source

IsAtLeast

pub func IsAtLeast(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Whether this version follows other or matches it, which is how a minimum requirement is written. self is borrowed and other is read by value. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this version is the same or newer

Source

Operators

==

pub func ==(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Equality by precedence, the operator spelling of IsEqualTo. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether the two are equal

Source

!=

pub func !=(
    self: &SemanticVersion,
    other: SemanticVersion
) -> bool

Inequality by precedence. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether the two differ

Source

<

pub func <(self: &SemanticVersion, other: SemanticVersion) -> bool

Precedence ordering, the operator spelling of IsLessThan. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this one is less

Source

<=

pub func <=(self: &SemanticVersion, other: SemanticVersion) -> bool

Precedence ordering, the operator spelling of IsAtMost. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this one is less or equal

Source

>

pub func >(self: &SemanticVersion, other: SemanticVersion) -> bool

Precedence ordering, the operator spelling of IsGreaterThan. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this one is greater

Source

>=

pub func >=(self: &SemanticVersion, other: SemanticVersion) -> bool

Precedence ordering, the operator spelling of IsAtLeast. Cannot fail. Runs in constant time and allocates nothing.

NameTypeDescription
otherSemanticVersionthe value to compare against

Returns: whether this one is greater or equal

Source