/// Open a version by matching it against the given string.
Open a version by matching it against the given string.
Open a version by matching it against the given string .
pub fn open(version: impl AsRef<str>) -> Result<Option<Version>> {
        let version_re = Regex::new(r"^(\d+)\.(\d+)\.(\d+)(-.+\.(\d+))?$")?;
        let version = version.as_ref();
        let m = match version_re.captures(version) {
            Some(m) => m,
            None => return Ok(None),
        };
        let major: u32 = str::parse(&m[1])?;
        let minor: u32 = str::parse(&m[2])?;
        let patch: u32 = str::parse(&m[3])?;
        let pre: Option<u32> = m.get(5).map(|s| str::parse(s.as_str())).transpose()?;
        Ok(Some(Self {
            base: version.to_string(),
            major,
            minor,
            patch,
            pre,
        }))
    }
pub fn open ( version : impl AsRef < str > ) -> Result < Option < Version > > { let version_re = Regex :: new ( r"^(\d+)\.(\d+)\.(\d+)(-.+\.(\d+))?$" ) ? ; let version = version . as_ref ( ) ; let m = match version_re . captures ( version ) { Some ( m ) => m , None => return Ok ( None ) , } ; let major : u32 = str :: parse ( & m [ 1 ] ) ? ; let minor : u32 = str :: parse ( & m [ 2 ] ) ? ; let patch : u32 = str :: parse ( & m [ 3 ] ) ? ; let pre : Option < u32 > = m . get ( 5 ) . map ( | s | str :: parse ( s . as_str ( ) ) ) . transpose ( ) ? ; Ok ( Some ( Self { base : version . to_string ( ) , major , minor , patch , pre , } ) ) }
Open a version by matching it against the given string.
Open a version by matching it against the given string .
version
impl AsRef<str>