mod version#
- module version#
Simple version comparison for EasyBuild-style versions (X.Y.Z or year.Z).
This targets EasyBuild-style version strings, not full PEP 440 / semver. A version decomposes into an ordered run of tokens: maximal digit runs parse as Num, maximal alphabetic runs parse as Alpha (case-folded to lowercase), and any other character (dot, hyphen, underscore, …) is a separator that is dropped. Example: 1.0rc1 tokenizes to Num(1), Num(0), Alpha(rc), Num(1); 2025a tokenizes to Num(2025), Alpha(a).
Comparison walks both token sequences position by position. Two Num tokens compare numerically; two Alpha tokens compare lexicographically (so 2025a is before 2025b). A Num against a missing token pads the missing side with zero. An Alpha against a missing token is treated as a pre-release suffix (rc, alpha, beta, or a bare trailing letter) that sorts before the side with nothing more. Mixed Num versus Alpha at the same position is rare for EasyBuild; Num sorts before Alpha there for a total deterministic order.
Functions
- fn cmp_version(a: &str, b: &str) -> Ordering#
- fn matches_req(version: &str, req: &str) -> bool#
Version requirements accept exact equality, ordered comparisons, bare exact versions, and comma-separated conjunctions of those clauses.
A compound requirement matches only if every non-empty clause matches.
- fn parse_version_parts(v: &str) -> Vec<Part>#
Tokenize a version string into an ordered run of numeric and alphabetic parts, dropping separator characters. See the module docs for the exact tokenization and comparison rules.
Enums