Function semver_parser::version::parse [−][src]
pub fn parse(input: &str) -> Result<Version, Error<'_>>
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);