solcompat-core 0.1.1

Compatibility data model and deterministic rule engine for SolCompat
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
//! Shared version syntax; callers retain their own error classification.
use anyhow::Result;
use semver::Version;
pub(crate) fn parse_version(value: &str) -> Option<Version> {
    let value = value.trim_start_matches('v');
    Version::parse(value)
        .ok()
        .or_else(|| Version::parse(&format!("{value}.0")).ok())
}
pub(crate) fn version(value: &str, label: &str) -> Result<Version> {
    parse_version(value).ok_or_else(|| anyhow::anyhow!("invalid {label} version: {value}"))
}