Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 596 Bytes

semver-prerelease.zh.md

File metadata and controls

23 lines (15 loc) · 596 Bytes

检查给定版本,是否为预发布版本。

[![semver-badge]][semver] [![cat-config-badge]][cat-config]

给出两个版本,is_prerelease断言一个是预发布,另一个不是。

extern crate semver;

use semver::{Version, SemVerError};

fn main() -> Result<(), SemVerError> {
    let version_1 = Version::parse("1.0.0-alpha")?;
    let version_2 = Version::parse("1.0.0")?;

    assert!(version_1.is_prerelease());
    assert!(!version_2.is_prerelease());

    Ok(())
}