summaryrefslogtreecommitdiff
path: root/src/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/map.rs b/src/map.rs
index 671318e..874e537 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -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),
)