diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-11-07 09:22:02 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-11-07 09:22:02 +0200 |
commit | 3efdb0d59897b9ef6f24bdfea5d2781912f33343 (patch) | |
tree | eaecc912f61cf798e4918b0317f3b97a119ee19d /src/map.rs | |
parent | 498a88aaf124a355fb59dc0f51284ded0b8583a6 (diff) | |
download | roadmap-3efdb0d59897b9ef6f24bdfea5d2781912f33343.tar.gz |
chore: clean up code based on clippy warnings
Sponsored-by: author
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -12,7 +12,7 @@ pub type RoadmapResult<T> = Result<T, RoadmapError>; /// /// This stores all the steps needed to reach the end goal. See the /// crate leve documentation for an example. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct Roadmap { steps: Vec<Step>, } @@ -21,8 +21,8 @@ impl Roadmap { /// Create a new, empty roadmap. /// /// You probably want the `from_yaml` function instead. - pub fn new() -> Roadmap { - Roadmap { steps: vec![] } + pub fn new() -> Self { + Self::default() } // Find steps that nothing depends on. @@ -45,7 +45,7 @@ impl Roadmap { /// Get a step, given its name. pub fn get_step(&self, name: &str) -> Option<&Step> { - self.steps.iter().filter(|step| step.name() == name).next() + self.steps.iter().find(|step| step.name() == name) } /// Add a step to the roadmap. @@ -122,7 +122,7 @@ impl Roadmap { /// Should status be goal? In other words, does any other step /// depend on this one? pub fn is_goal(&self, step: &Step) -> bool { - self.steps.iter().all(|other| !other.depends_on(&step)) + self.steps.iter().all(|other| !other.depends_on(step)) } // Validate that the parsed, constructed roadmap is valid. @@ -137,7 +137,7 @@ impl Roadmap { let names: Vec<String> = goals.iter().map(|s| s.name().into()).collect(); return Err(RoadmapError::ManyGoals { count: n, - names: names, + names, }); } } @@ -169,7 +169,7 @@ impl Roadmap { format!( "{} [label=\"{}\" style=filled fillcolor=\"{}\" shape=\"{}\"];\n", step.name(), - fill(&step.label(), label_width).replace("\n", "\\n"), + fill(step.label(), label_width).replace("\n", "\\n"), Roadmap::get_status_color(step), Roadmap::get_status_shape(step), ) |