summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/poem.rs14
-rw-r--r--src/poem/elements/verse.rs8
-rw-r--r--src/poem/elements/verse/logic.rs2
-rw-r--r--src/poem/read.rs6
4 files changed, 14 insertions, 16 deletions
diff --git a/src/poem.rs b/src/poem.rs
index e330679..1c21d8b 100644
--- a/src/poem.rs
+++ b/src/poem.rs
@@ -295,7 +295,7 @@ mod tests {
let verse = verses.next().unwrap();
assert_eq!(verse.verb(), "ls");
- assert_eq!(verse.clause().unwrap(), vec!["-la".to_string()]);
+ assert_eq!(verse.clause(), vec!["-la".to_string()]);
assert_eq!(verse.meter, Rune::Couplet);
let verse = verses.next().unwrap();
@@ -304,7 +304,7 @@ mod tests {
let verse = verses.next().unwrap();
assert_eq!(verse.verb(), "echo");
- assert_eq!(verse.clause().unwrap(), vec!["hello".to_string()]);
+ assert_eq!(verse.clause(), vec!["hello".to_string()]);
assert_eq!(verse.meter, Rune::Couplet);
let verse = verses.next().unwrap();
@@ -313,7 +313,7 @@ mod tests {
let verse = verses.next().unwrap();
assert_eq!(verse.verb(), "sleep");
- assert_eq!(verse.clause().unwrap(), vec!["2".to_string()]);
+ assert_eq!(verse.clause(), vec!["2".to_string()]);
assert_eq!(verse.meter, Rune::Quiet);
}
@@ -358,7 +358,7 @@ mod tests {
let verse = verses.next().unwrap();
assert_eq!(verse.verb(), "ps");
- assert_eq!(verse.clause().unwrap(), vec!["aux".to_string()]);
+ assert_eq!(verse.clause(), vec!["aux".to_string()]);
assert_eq!(verse.meter, Rune::Couplet);
let verse = verses.next().unwrap();
@@ -367,7 +367,7 @@ mod tests {
let verse = verses.next().unwrap();
assert_eq!(verse.verb(), "sleep");
- assert_eq!(verse.clause().unwrap(), vec!["2".to_string()]);
+ assert_eq!(verse.clause(), vec!["2".to_string()]);
assert_eq!(verse.meter, Rune::Continue);
}
@@ -424,14 +424,14 @@ mod tests {
let poetry = "cd ~".to_string();
let poem = Poem::read(poetry, &mut Environment::new()).unwrap();
assert_eq!(poem[0].verb(), "cd");
- assert_eq!(poem[0].clause(), Some(vec![env!("HOME").to_string()]));
+ assert_eq!(poem[0].clause(), vec![env!("HOME").to_string()]);
let poetry = "cd ~/Code/dwarvish".to_string();
let poem = Poem::read(poetry, &mut Environment::new()).unwrap();
assert_eq!(poem[0].verb(), "cd");
assert_eq!(
poem[0].clause(),
- Some(vec![format!("{}/Code/dwarvish", env!("HOME")).to_string()])
+ vec![format!("{}/Code/dwarvish", env!("HOME")).to_string()]
);
assert_eq!(poem[0].meter, Rune::None);
}
diff --git a/src/poem/elements/verse.rs b/src/poem/elements/verse.rs
index 1c5bcc1..9ebd31d 100644
--- a/src/poem/elements/verse.rs
+++ b/src/poem/elements/verse.rs
@@ -140,11 +140,11 @@ impl Verse {
/// Get the [Verse]'s clause
///
/// Return program arguments, if they exist
- pub fn clause(&self) -> Option<Vec<String>> {
+ pub fn clause(&self) -> Vec<String> {
match self.stanza.len() {
- 0 => None,
- 1 => None,
- _ => Some(self.stanza[1..].to_vec()),
+ 0 => vec![],
+ 1 => vec![],
+ _ => self.stanza[1..].to_vec(),
}
}
diff --git a/src/poem/elements/verse/logic.rs b/src/poem/elements/verse/logic.rs
index e7ed4df..41b736b 100644
--- a/src/poem/elements/verse/logic.rs
+++ b/src/poem/elements/verse/logic.rs
@@ -15,7 +15,7 @@
#[macro_export]
macro_rules! incant {
($verb:expr, $command:expr, $out:expr, $pids:expr, $env:expr, $self:expr) => {{
- $command.args($self.clause().unwrap_or(vec![]));
+ $command.args($self.clause());
// Determine couplet status
if $self.couplet == 1 {
diff --git a/src/poem/read.rs b/src/poem/read.rs
index 7f3ae32..99e9aa6 100644
--- a/src/poem/read.rs
+++ b/src/poem/read.rs
@@ -149,10 +149,8 @@ impl Appendable for Poem {
lv.ep = verse.ep.clone();
lv.poems = verse.poems.clone();
lv.meter = verse.meter;
- if verse.clause().is_some() {
- for word in verse.clause().unwrap().iter() {
- lv.stanza.push(word.to_string());
- }
+ for word in verse.clause().iter() {
+ lv.stanza.push(word.to_string());
}
// Push verse(s)