Skip to content

Commit

Permalink
tidy: Extract let mut part out of parts block in version.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rasendubi committed May 3, 2019
1 parent 1937bf2 commit bacf792
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/tools/tidy/src/features/version.rs
Expand Up @@ -31,15 +31,13 @@ impl FromStr for Version {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut iter = s.split('.').map(|part| Ok(part.parse()?));

let parts = {
let mut part = || {
iter.next()
.unwrap_or(Err(ParseVersionError::WrongNumberOfParts))
};

[part()?, part()?, part()?]
let mut part = || {
iter.next()
.unwrap_or(Err(ParseVersionError::WrongNumberOfParts))
};

let parts = [part()?, part()?, part()?];

if let Some(_) = iter.next() {
// Ensure we don't have more than 3 parts.
return Err(ParseVersionError::WrongNumberOfParts);
Expand Down

0 comments on commit bacf792

Please sign in to comment.