Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
Simplified the changeset work and ran cargo fmt
  • Loading branch information
marcaddeo committed Oct 5, 2019
1 parent 24f6a5e commit b349bfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
46 changes: 8 additions & 38 deletions src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use chrono::NaiveDate;
use derive_builder::Builder;
use failure::Fail;
use fstrings::*;
use indexmap::indexmap;
use semver::Version;
use serde_derive::{Deserialize, Serialize};
use indexmap::indexmap;
use std::fmt;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -107,7 +107,7 @@ impl fmt::Display for Release {
}

// Release changes.
let mut changesets = indexmap!{
let mut changesets = indexmap! {
"Added" => Vec::new(),
"Changed" => Vec::new(),
"Deprecated" => Vec::new(),
Expand All @@ -116,42 +116,12 @@ impl fmt::Display for Release {
"Security" => Vec::new(),
};
self.changes.iter().for_each(|change| match change {
Added(_) => match changesets.get_mut("Added") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Added", vec![change]);
}
},
Changed(_) => match changesets.get_mut("Changed") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Changed", vec![change]);
}
},
Deprecated(_) => match changesets.get_mut("Deprecated") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Deprecated", vec![change]);
}
},
Removed(_) => match changesets.get_mut("Removed") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Removed", vec![change]);
}
},
Fixed(_) => match changesets.get_mut("Fixed") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Fixed", vec![change]);
}
},
Security(_) => match changesets.get_mut("Security") {
Some(changes) => changes.push(change),
None => {
changesets.insert("Security", vec![change]);
}
},
Added(_) => changesets.get_mut("Added").unwrap().push(change),
Changed(_) => changesets.get_mut("Changed").unwrap().push(change),
Deprecated(_) => changesets.get_mut("Deprecated").unwrap().push(change),
Removed(_) => changesets.get_mut("Removed").unwrap().push(change),
Fixed(_) => changesets.get_mut("Fixed").unwrap().push(change),
Security(_) => changesets.get_mut("Security").unwrap().push(change),
});

changesets = changesets
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use clap::{app_from_crate, crate_authors, crate_description, crate_name, crate_version, AppSettings, Arg};
use clap::{
app_from_crate, crate_authors, crate_description, crate_name, crate_version, AppSettings, Arg,
};
use clparse::ChangelogParser;
use failure::Error;
use std::io::{self, Read};
Expand Down

0 comments on commit b349bfe

Please sign in to comment.