diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-09-19 08:14:30 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-09-19 08:14:30 +0300 |
commit | 661ef0b06c372fcfa8db87646053a2c2f53ab9bb (patch) | |
tree | 2ebcd90e5ed02791b48d403400c4cf7d1866db5a /src/lib.rs | |
parent | c8d1010a0ac8288a5bd11d02843d18092257af51 (diff) | |
download | roadmap-661ef0b06c372fcfa8db87646053a2c2f53ab9bb.tar.gz |
Chagne: Step returns lifetimed referennce to name, label
This avoids making unnecessary copies of the string.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -15,8 +15,8 @@ //! assert_eq!(r.steps().len(), 0); //! //! let endgoal = roadmap::Step::new("endgoal", "the end goal"); -//! assert_eq!(endgoal.name(), "endgoal".to_string()); -//! assert_eq!(endgoal.label(), "the end goal".to_string()); +//! assert_eq!(endgoal.name(), "endgoal"); +//! assert_eq!(endgoal.label(), "the end goal"); //! r.add_step(endgoal)?; //! assert_eq!(r.steps().len(), 1); //! @@ -45,13 +45,13 @@ impl Step { } /// Return the name of a step. - pub fn name(&self) -> String { - self.name.to_string() + pub fn name<'a>(&'a self) -> &'a str { + &self.name } /// Return the label of a step. - pub fn label(&self) -> String { - self.label.to_string() + pub fn label<'a>(&'a self) -> &'a str { + &self.label } /// Return vector of names of dependencies for a step. @@ -85,7 +85,7 @@ impl Roadmap { pub fn steps(&self) -> Vec<String> { let mut names = vec![]; for step in self.steps.iter() { - names.push(step.name()); + names.push(step.name().to_string()); } names } |