diff options
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\" { |