summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-09-19 08:14:30 +0300
committerLars Wirzenius <liw@liw.fi>2019-09-19 08:14:30 +0300
commit661ef0b06c372fcfa8db87646053a2c2f53ab9bb (patch)
tree2ebcd90e5ed02791b48d403400c4cf7d1866db5a /src
parentc8d1010a0ac8288a5bd11d02843d18092257af51 (diff)
downloadroadmap-661ef0b06c372fcfa8db87646053a2c2f53ab9bb.tar.gz
Chagne: Step returns lifetimed referennce to name, label
This avoids making unnecessary copies of the string.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d0f06df..d1f9fa4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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
}