pub fn parse(input: &str) -> Result<Version, Error<'_>>
Expand description
Function for parsing version string to Version
.
Returns Result<
Version
, String>
, where String
represents an error while parsing.
ยงExamples
Parsing Version
from string and checking its fields:
use semver_parser::version;
let version = version::parse("0.1.2-alpha1")?;
assert_eq!(version.major, 0);
assert_eq!(version.minor, 1);
assert_eq!(version.patch, 2);
let expected_pre = vec![version::Identifier::AlphaNumeric(String::from("alpha1"))];
assert_eq!(expected_pre, version.pre);