diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-10-03 22:31:09 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-10-03 22:31:09 +0300 |
commit | 10214e0295d72c88cd61085da67b9fc0f01e9728 (patch) | |
tree | 4ee77d302d568147ea4b9321472d12ba820c5776 /src/map.rs | |
parent | acbdce9918d7f7c0443fd6857b79b2737d1ce9ed (diff) | |
download | roadmap-10214e0295d72c88cd61085da67b9fc0f01e9728.tar.gz |
Change: add_step can't fail, don't return Result
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -4,9 +4,10 @@ pub use crate::from_yaml; pub use crate::Status; pub use crate::Step; -/// Represent a full project roadmap. This stores all the steps needed -/// to reach the end goal. See the crate leve documentation for an -/// example. +/// Represent a full project roadmap. +/// +/// This stores all the steps needed to reach the end goal. See the +/// crate leve documentation for an example. #[derive(Clone,Debug)] pub struct Roadmap { steps: Vec<Step>, @@ -14,6 +15,8 @@ pub struct Roadmap { impl Roadmap { /// Create a new, empty roadmap. + /// + /// You probably want the `from_yaml` function instead. pub fn new() -> Roadmap { Roadmap { steps: vec![] } } @@ -26,7 +29,7 @@ impl Roadmap { .count() } - /// Return list of step names. + /// Iterate over step names. pub fn step_names(&self) -> impl Iterator<Item=&str> { self.steps.iter().map(|step| step.name()) } @@ -36,11 +39,9 @@ impl Roadmap { self.steps.iter().filter(|step| step.name() == name).next() } - /// Add a step to the roadmap. This may fail, if there's a step - /// with that name already. - pub fn add_step(&mut self, step: &Step) -> Result<(), Box<dyn std::error::Error>> { + /// Add a step to the roadmap. + pub fn add_step(&mut self, step: &Step) { self.steps.push(step.clone()); - Ok(()) } // Get iterator over refs to steps. @@ -190,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).unwrap(); + roadmap.add_step(&first); let names: Vec<&str> = roadmap.step_names().collect(); assert_eq!(names, vec!["first"]); } @@ -199,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).unwrap(); + roadmap.add_step(&first); let gotit = roadmap.get_step("first").unwrap(); assert_eq!(gotit.name(), "first"); assert_eq!(gotit.label(), "the first step"); @@ -258,8 +259,8 @@ blocked: let mut second = Step::new("second", ""); second.add_dependency("first"); second.set_status(Status::Goal); - roadmap.add_step(&first).unwrap(); - roadmap.add_step(&second).unwrap(); + roadmap.add_step(&first); + roadmap.add_step(&second); assert_eq!( roadmap.as_dot(999).unwrap(), "digraph \"roadmap\" { |