summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-10-04 09:56:14 +0300
committerLars Wirzenius <liw@liw.fi>2019-10-04 09:56:14 +0300
commit256e3de75458d015b3af75260022436e89e0190c (patch)
tree0074c86aaa453059868e7d3b47247f2774965cd5
parent10214e0295d72c88cd61085da67b9fc0f01e9728 (diff)
downloadroadmap-256e3de75458d015b3af75260022436e89e0190c.tar.gz
Change: pass in step, push it to vector, instead of ref and cloning
-rw-r--r--src/map.rs12
-rw-r--r--src/parser.rs2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/map.rs b/src/map.rs
index f442ecb..cd1cb46 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -40,8 +40,8 @@ impl Roadmap {
}
/// Add a step to the roadmap.
- pub fn add_step(&mut self, step: &Step) {
- self.steps.push(step.clone());
+ pub fn add_step(&mut self, step: Step) {
+ self.steps.push(step);
}
// Get iterator over refs to steps.
@@ -191,7 +191,7 @@ mod tests {
fn add_step_to_roadmap() {
let mut roadmap = Roadmap::new();
let first = Step::new("first", "the first step");
- roadmap.add_step(&first);
+ roadmap.add_step(first);
let names: Vec<&str> = roadmap.step_names().collect();
assert_eq!(names, vec!["first"]);
}
@@ -200,7 +200,7 @@ mod tests {
fn get_step_from_roadmap() {
let mut roadmap = Roadmap::new();
let first = Step::new("first", "the first step");
- roadmap.add_step(&first);
+ roadmap.add_step(first);
let gotit = roadmap.get_step("first").unwrap();
assert_eq!(gotit.name(), "first");
assert_eq!(gotit.label(), "the first step");
@@ -259,8 +259,8 @@ blocked:
let mut second = Step::new("second", "");
second.add_dependency("first");
second.set_status(Status::Goal);
- roadmap.add_step(&first);
- roadmap.add_step(&second);
+ roadmap.add_step(first);
+ roadmap.add_step(second);
assert_eq!(
roadmap.as_dot(999).unwrap(),
"digraph \"roadmap\" {
diff --git a/src/parser.rs b/src/parser.rs
index ac917eb..cb1c5ce 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -17,7 +17,7 @@ pub fn from_yaml(yaml: &str) -> Result<Roadmap, Box<dyn Error>> {
for (name, value) in map {
let step = step_from_value(&name, &value)?;
- roadmap.add_step(&step);
+ roadmap.add_step(step);
}
validate(&roadmap)?;