diff --git a/src/version.rs b/src/version.rs index 75441d9..00751ce 100644 --- a/src/version.rs +++ b/src/version.rs @@ -290,12 +290,6 @@ pub struct Version { /// > identifier by a plus. Local version labels have no specific semantics assigned, but some /// > syntactic restrictions are imposed. pub local: Option>, - /// The first item of release or 0 if unavailable. - pub major: usize, - /// The second item of release or 0 if unavailable. - pub minor: usize, - /// The third item of release or 0 if unavailable. - pub micro: usize, } #[cfg(feature = "pyo3")] @@ -353,17 +347,17 @@ impl PyVersion { /// The first item of release or 0 if unavailable. #[getter] pub fn major(&self) -> usize { - self.0.major + if !self.release().is_empty() {self.release()[0]} else {0} } /// The second item of release or 0 if unavailable. #[getter] pub fn minor(&self) -> usize { - self.0.minor + if self.release().len() > 1 {self.release()[1]} else {0} } /// The third item of release or 0 if unavailable. #[getter] pub fn micro(&self) -> usize { - self.0.micro + if self.release().len() > 2 {self.release()[2]} else {0} } /// Parses a PEP 440 version string @@ -448,9 +442,6 @@ impl Version { post: None, dev: None, local: None, - major: 0, - minor: 0, - micro: 0, } } @@ -789,9 +780,7 @@ impl Version { .split('.') .map(|segment| segment.parse::().map_err(|err| err.to_string())) .collect::, String>>()?; - let major = if !release.is_empty() { release[0] } else { 0 }; - let minor = if release.len() >= 2 { release[1] } else { 0 }; - let micro = if release.len() >= 3 { release[2] } else { 0 }; + let star = captures.name("trailing_dot_star").is_some(); if star { if pre.is_some() { @@ -817,9 +806,6 @@ impl Version { post, dev, local, - major, - minor, - micro, }; Ok((version, star)) } diff --git a/src/version_specifier.rs b/src/version_specifier.rs index 5ff4a21..af3a5bd 100644 --- a/src/version_specifier.rs +++ b/src/version_specifier.rs @@ -1039,9 +1039,6 @@ mod test { post: None, dev: None, local: None, - major: 0, - minor: 9, - micro: 0, } }, VersionSpecifier { @@ -1053,9 +1050,6 @@ mod test { post: None, dev: None, local: None, - major: 1, - minor: 0, - micro: 0, } }, VersionSpecifier { @@ -1067,9 +1061,6 @@ mod test { post: None, dev: None, local: None, - major: 1, - minor: 3, - micro: 4, } }, VersionSpecifier { @@ -1081,9 +1072,6 @@ mod test { post: None, dev: None, local: None, - major: 2, - minor: 0, - micro: 0, } } ]