File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -27,15 +27,13 @@ impl Version {
2727 }
2828
2929 pub fn parse ( s : & str ) -> Option < Self > {
30- let s = s. lines ( ) . next ( ) ?. trim ( ) ;
31- let s = s. rfind ( '_' ) . map ( |i| & s[ ..i] ) . unwrap_or ( s) ;
32- let mut parts = s. split ( '.' ) ;
33- let v = Self :: new (
34- parts. next ( ) ?. parse ( ) . ok ( ) ?,
35- parts. next ( ) ?. parse ( ) . ok ( ) ?,
36- parts. next ( ) ?. parse ( ) . ok ( ) ?,
37- ) ;
38- parts. next ( ) . map_or ( Some ( v) , |_| None )
30+ let re = Regex :: new ( r"^(1)\.(8|10)\.(\d\d?)(_\d+)?(-patch\d+)?$" ) . ok ( ) ?;
31+ let captures = re. captures ( s) ?;
32+ Some ( Self {
33+ major : captures. get ( 1 ) . and_then ( |c| c. as_str ( ) . parse :: < u8 > ( ) . ok ( ) ) ?,
34+ minor : captures. get ( 2 ) . and_then ( |c| c. as_str ( ) . parse :: < u8 > ( ) . ok ( ) ) ?,
35+ micro : captures. get ( 3 ) . and_then ( |c| c. as_str ( ) . parse :: < u8 > ( ) . ok ( ) ) ?,
36+ } )
3937 }
4038
4139 pub fn is_valid ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments