diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-09-20 08:50:56 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-09-20 08:50:56 +0300 |
commit | 8ec68193b17d68ea3a13b63e1d8a0dc838f2bc8f (patch) | |
tree | 8430bb9ec58d170e76494c2281cc019e359c6a06 /src | |
parent | 873d1d111037f4f94a9db3991a2d9d2b9e88d262 (diff) | |
download | roadmap-8ec68193b17d68ea3a13b63e1d8a0dc838f2bc8f.tar.gz |
Change: implement get_step
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -102,7 +102,12 @@ impl Roadmap { } /// Get a step, given its name. - pub fn get_step<'a>(&'a self, _name: &str) -> Option<&'a mut Step> { + pub fn get_step<'a>(&'a mut self, name: &str) -> Option<&'a mut Step> { + for step in self.steps.iter_mut() { + if step.name() == name { + return Some(step); + } + } None } @@ -174,4 +179,14 @@ mod tests { assert_eq!(roadmap.step_names().len(), 1); assert_eq!(roadmap.step_names(), vec!["first"]); } + + #[test] + fn get_step_from_roadmap() { + let mut roadmap = Roadmap::new(); + let first = Step::new("first", "the first step"); + roadmap.add_step(&first).unwrap(); + let gotit = roadmap.get_step("first").unwrap(); + assert_eq!(gotit.name(), "first"); + assert_eq!(gotit.label(), "the first step"); + } } |