[][src]Function built::util::parse_versions

pub fn parse_versions<'a, T>(
    name_and_versions: T
) -> impl Iterator<Item = (&'a str, Version)> where
    T: IntoIterator<Item = &'a (&'a str, &'a str)>, 

Parses version-strings with semver::Version::parse().

This function is only available if built was compiled with the semver feature.

The function takes a reference to an array of names and version numbers as serialized by built and returns an iterator over the unchanged names and parsed version numbers.

pub mod build_info {
    pub const DEPENDENCIES: [(&'static str, &'static str); 1] = [("built", "0.1.0")];
}

let deps = build_info::DEPENDENCIES;
assert!(built::util::parse_versions(&deps)
                     .any(|(name, ver)| name == "built" &&
                                        ver >= semver::Version::parse("0.1.0").unwrap()));

Panics

If a version can't be parsed by semver::Version::parse(). This should never happen with version strings provided by Cargo and built.