diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-10-04 10:42:10 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-10-04 10:42:10 +0300 |
commit | d3a81e80937582f8eb5212296d68104c182780b8 (patch) | |
tree | b7400e262ea6c4e6d79b9b770f2508dfd6af4a37 /src/step.rs | |
parent | 2ff6d1af902fb1b7d969e6f043798c1ebcb9ba90 (diff) | |
download | roadmap-d3a81e80937582f8eb5212296d68104c182780b8.tar.gz |
Change: dependencies() to return iterator over &str
This avoids making temporary, pointless copies of Strings.
Diffstat (limited to 'src/step.rs')
-rw-r--r-- | src/step.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/step.rs b/src/step.rs index a37f23c..6088400 100644 --- a/src/step.rs +++ b/src/step.rs @@ -45,8 +45,8 @@ impl Step { } /// Return vector of names of dependencies for a step. - pub fn dependencies(&self) -> impl Iterator<Item = &String> { - self.depends.iter() + pub fn dependencies(&self) -> impl Iterator<Item = &str> { + self.depends.iter().map(|s| s.as_str()) } /// Add the name of a dependency to step. Steps are referred by @@ -86,7 +86,7 @@ mod tests { fn add_step_dependency() { let mut second = Step::new("second", "the second step"); second.add_dependency("first"); - let deps: Vec<&String> = second.dependencies().collect(); + let deps: Vec<&str> = second.dependencies().collect(); assert_eq!(deps, vec!["first"]); } } |