Skip to content

Commit

Permalink
Simplify version parsing
Browse files Browse the repository at this point in the history
Co-authored-by: Mara Bos <[email protected]>
  • Loading branch information
taiki-e and m-ou-se committed May 12, 2022
1 parent dcd0889 commit b62546a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,7 @@ impl Version {
//
// CMake suite maintained and supported by Kitware (kitware.com/cmake).
// ```
let version = s.lines().find(|s| s.starts_with("cmake version "))?;
let version = &version["cmake version ".len()..]; // strip prefix
let version = s.lines().next()?.strip_prefix("cmake version ")?;
let mut digits = version.splitn(3, '.'); // split version string to major minor patch
let major = digits.next()?.parse::<u32>().ok()?;
let minor = digits.next()?.parse::<u32>().ok()?;
Expand Down

0 comments on commit b62546a

Please sign in to comment.