Function split_canonical_version
pub fn split_canonical_version(version: &str) -> Option<(&str, Option<&str>)>Expand description
Splits the full version into its canonical version and the remaining
version suffix, as used by canonical interface names in the component
model.
The returned canonical version and version suffix are subslices of
version whose concatenation is version. In a canonical interface name
the canonical version is the version in the name, e.g. the 0.2 in
a:b/c@0.2, and the version suffix, if any, is its versionsuffix. With
version of the form major.minor.patch(-pre)(+build) the canonical
version is:
major, if there’s no-preandmajorisn’t 0.0.minor, if there’s no-preandminorisn’t 0.versionwithout+buildotherwise, i.e. for0.0.patchor when there’s a-pre.
The version suffix is the rest of version, which always includes the
+build, or None if that’s empty.
Returns None if version isn’t a valid semantic version.
§Examples
use wasmparser::names::split_canonical_version;
assert_eq!(split_canonical_version("1.2.3+abc"), Some(("1", Some(".2.3+abc"))));
assert_eq!(split_canonical_version("0.2.1"), Some(("0.2", Some(".1"))));
assert_eq!(split_canonical_version("0.0.1"), Some(("0.0.1", None)));
assert_eq!(split_canonical_version("0.0.1+b"), Some(("0.0.1", Some("+b"))));
assert_eq!(split_canonical_version("1.0.0-rc1"), Some(("1.0.0-rc1", None)));
assert_eq!(split_canonical_version("1.2"), None);