pub struct Bound { /* private fields */ }Expand description
One end of a version interval. Mirrors Composer\Semver\Constraint\Bound:
a normalized version string and whether the endpoint itself is
included in the interval.
Implementations§
Source§impl Bound
impl Bound
Sourcepub fn new(version: String, is_inclusive: bool) -> Self
pub fn new(version: String, is_inclusive: bool) -> Self
Construct a bound from a normalized version string.
Sourcepub fn zero() -> Self
pub fn zero() -> Self
Composer’s Bound::zero() — 0.0.0.0-dev inclusive. The lower
bound of any constraint with no real floor (<X, !=X, *).
Sourcepub fn positive_infinity() -> Self
pub fn positive_infinity() -> Self
Composer’s Bound::positiveInfinity() — <PHP_INT_MAX>.0.0.0
exclusive. The upper bound of any constraint with no real ceiling
(>X, >=X, !=X, *).
Sourcepub fn is_inclusive(&self) -> bool
pub fn is_inclusive(&self) -> bool
Whether the endpoint is part of the interval.
Sourcepub fn is_positive_infinity(&self) -> bool
pub fn is_positive_infinity(&self) -> bool
Matches Bound::isPositiveInfinity().
Sourcepub fn compare_to(&self, other: &Bound, gt: bool) -> bool
pub fn compare_to(&self, other: &Bound, gt: bool) -> bool
Port of Bound::compareTo($other, $operator) with $operator
expressed as gt (true → '>', false → '<'). Returns
whether self lies strictly beyond other in the requested
direction; two structurally-equal bounds compare false (as in
Composer’s if ($this == $other) return false).
Sourcepub fn version_cmp(&self, other: &Bound) -> Ordering
pub fn version_cmp(&self, other: &Bound) -> Ordering
Order the two endpoints purely by version body (ignoring
inclusivity), the way PHP’s version_compare would for these
normalized strings. The sentinels parse like any other numeric
version (0.0.0.0-dev sorts below every real version; the
PHP_INT_MAX body sorts above), so a plain Version
comparison reproduces the upstream ordering.