summaryrefslogtreecommitdiff
path: root/src/steps.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-12-14 16:48:56 +0200
committerLars Wirzenius <liw@liw.fi>2019-12-14 16:48:56 +0200
commit2be57a8258be1496939bc198e7e4016c37887f62 (patch)
tree258a215026bcf9ffd8c4cdba3298f0052bf2e91e /src/steps.rs
parentfa9a4faeace06d87f9dd4cffea8efce2246ce81c (diff)
downloadsubplot-2be57a8258be1496939bc198e7e4016c37887f62.tar.gz
Add: UnknownStepKind error
Diffstat (limited to 'src/steps.rs')
-rw-r--r--src/steps.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/steps.rs b/src/steps.rs
index 86ca0a9..7fbb8a8 100644
--- a/src/steps.rs
+++ b/src/steps.rs
@@ -1,4 +1,8 @@
#[deny(missing_docs)]
+
+use crate::{Error, Result};
+
+
/// A scenario step.
///
/// The scenario parser creates these kinds of data structures to
@@ -34,14 +38,14 @@ impl ScenarioStep {
}
/// Construct a step from a line in a scenario.
- pub fn from_str(text: &str) -> Option<ScenarioStep> {
+ pub fn from_str(text: &str) -> Result<ScenarioStep> {
let mut words = text.split_whitespace();
let kind = match words.next() {
Some("given") => StepKind::Given,
Some("when") => StepKind::When,
Some("then") => StepKind::Then,
- _ => return None,
+ _ => return Err(Error::UnknownStepKind),
};
let mut joined = String::new();
@@ -52,7 +56,7 @@ impl ScenarioStep {
if joined.len() > 1 {
joined.pop();
}
- Some(ScenarioStep::new(kind, &joined))
+ Ok(ScenarioStep::new(kind, &joined))
}
}