summaryrefslogtreecommitdiff
path: root/subplotlib/src/step.rs
diff options
context:
space:
mode:
Diffstat (limited to 'subplotlib/src/step.rs')
-rw-r--r--subplotlib/src/step.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/subplotlib/src/step.rs b/subplotlib/src/step.rs
index b9c2a86..bbea249 100644
--- a/subplotlib/src/step.rs
+++ b/subplotlib/src/step.rs
@@ -22,10 +22,12 @@ use crate::types::StepResult;
/// ```
/// # use subplotlib::prelude::*;
///
-/// let step = ScenarioStep::new("step name", |ctx, ok| Ok(()), |scen| ());
+/// let step = ScenarioStep::new(
+/// "when everything works".to_string(), |ctx, ok| Ok(()), |scen| ()
+/// );
/// ```
pub struct ScenarioStep {
- name: String,
+ step_text: String,
func: Box<dyn Fn(&ScenarioContext, bool) -> StepResult>,
reg: Box<dyn Fn(&Scenario)>,
}
@@ -36,13 +38,13 @@ impl ScenarioStep {
/// This is used to construct a scenario step from a function which
/// takes the scenario context container. This will generally be
/// called from the generated build method for the step.
- pub fn new<F, R>(name: &str, func: F, reg: R) -> Self
+ pub fn new<F, R>(step_text: String, func: F, reg: R) -> Self
where
F: Fn(&ScenarioContext, bool) -> StepResult + 'static,
R: Fn(&Scenario) + 'static,
{
Self {
- name: name.to_string(),
+ step_text,
func: Box::new(func),
reg: Box::new(reg),
}
@@ -69,12 +71,12 @@ impl ScenarioStep {
// subsequent step calls may not be sound. There's not a lot we can
// do to ensure things are good except try.
let func = AssertUnwindSafe(|| (*self.func)(context, defuse_poison));
- catch_unwind(func).map_err(|e| Self::render_panic(self.name(), e))?
+ catch_unwind(func).map_err(|e| Self::render_panic(self.step_text(), e))?
}
- /// Return the name of this step
- pub fn name(&self) -> &str {
- &self.name
+ /// Return the full text of this step
+ pub fn step_text(&self) -> &str {
+ &self.step_text
}
/// Register any context types needed by this step