const-semver 0.1.4

Library for constructing semver-compatible Versions at compile-time
Documentation
#[macro_export]
macro_rules! ident {
    ($n:literal) => {
        $crate::Identifier::Numeric($n)
    };
    ($s:ident) => {
        $crate::Identifier::Alphanumeric(stringify!($s))
    };
}

#[macro_export]
macro_rules! version {
    ($major:literal,$minor:literal,$patch:literal $(- $( $pre:tt ),*)? $(+ $( $build:tt ),*)?) => {
        $crate::Version::new($major, $minor, $patch)
            .pre(&[
                $($( $crate::ident!($pre) ),*)?
            ])
            .build(&[
                $($( $crate::ident!($build) ),*)?
            ])
    };
}

#[cfg(test)]
mod tests {
    #[test]
    fn test_long_macro() {
        let version: semver::Version = version!(1, 2, 3 - alpha, 6, 4 + amd64).into();

        assert_eq!(version.major, 1);
        assert_eq!(version.minor, 2);
        assert_eq!(version.patch, 3);

        assert_eq!(
            version.build,
            vec![semver::Identifier::AlphaNumeric("amd64".to_string())]
        );
        assert_eq!(
            version,
            semver::Version::parse("1.2.3-alpha.6.4+amd64").unwrap()
        );
    }

    #[test]
    fn test_short_version() {
        let version: semver::Version = version!(1, 2, 0).into();
        assert_eq!(version, semver::Version::parse("1.2.0").unwrap());
    }
}