diff options
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -27,7 +27,10 @@ impl Roadmap { // Find steps that nothing depends on. fn goals(&self) -> Vec<&Step> { - self.steps.iter().filter(|step| self.is_goal(step)).collect() + self.steps + .iter() + .filter(|step| self.is_goal(step)) + .collect() } /// Count number of steps that nothing depends on. @@ -125,10 +128,18 @@ impl Roadmap { // Validate that the parsed, constructed roadmap is valid. pub fn validate(&self) -> RoadmapResult<()> { // Is there exactly one goal? - match self.count_goals() { + let goals = self.goals(); + let n = goals.len(); + match n { 0 => return Err(format!("the roadmap doesn't have a goal").into()), 1 => (), - _ => return Err(format!("must have exactly one goal for roadmap").into()), + _ => { + let mut names: Vec<&str> = goals.iter().map(|s| s.name()).collect(); + names.sort(); + let names = names.join(", "); + let msg = format!("only one goal allowed, found {}: {}", n, names); + return Err(msg.into()); + } } // Does every dependency exist? |