pubgrub/term

Terms represent positive or negative constraints over ranges.

Types

Relationship between two terms.

pub type Relation {
  Satisfied
  Contradicted
  Inconclusive
}

Constructors

  • Satisfied
  • Contradicted
  • Inconclusive

A constraint over versions.

pub type Term(v) {
  Positive(version_ranges.Ranges(v))
  Negative(version_ranges.Ranges(v))
}

Constructors

Values

pub fn any(compare: fn(v, v) -> order.Order) -> Term(v)

A term that accepts any version.

pub fn compare(term: Term(v)) -> fn(v, v) -> order.Order

Extract the compare function carried by a term.

pub fn contains(term: Term(v), version: v) -> Bool

Check whether a version is allowed by the term.

pub fn empty(compare: fn(v, v) -> order.Order) -> Term(v)

A term that accepts no versions.

pub fn equal(left: Term(v), right: Term(v)) -> Bool

True when two terms have the same polarity and range set.

pub fn exact(
  compare: fn(v, v) -> order.Order,
  version: v,
) -> Term(v)

A term that accepts exactly one version.

pub fn intersection(left: Term(v), right: Term(v)) -> Term(v)

Intersection of two terms.

pub fn is_any(term: Term(v)) -> Bool

True when the term allows all versions.

pub fn is_disjoint(left: Term(v), right: Term(v)) -> Bool

True if two terms do not overlap.

pub fn is_positive(term: Term(v)) -> Bool

True for positive terms.

pub fn negate(term: Term(v)) -> Term(v)

Flip a term from positive to negative (or vice versa).

pub fn relation_with(
  term: Term(v),
  other_terms_intersection: Term(v),
) -> Relation

Relation between a term and the intersection of other terms.

pub fn subset_of(left: Term(v), right: Term(v)) -> Bool

True if left is contained in right.

pub fn to_string(
  term: Term(v),
  range_to_string: fn(version_ranges.Ranges(v)) -> String,
) -> String

Render a term using a range formatter.

pub fn union(left: Term(v), right: Term(v)) -> Term(v)

Union of two terms.

pub fn unwrap_negative(term: Term(v)) -> version_ranges.Ranges(v)

Extract the negative range set or panic.

pub fn unwrap_positive(term: Term(v)) -> version_ranges.Ranges(v)

Extract the positive range set or panic.

Search Document