summaryrefslogtreecommitdiffstats
path: root/src/poem.rs
diff options
context:
space:
mode:
authorRory Dudley2024-09-02 22:23:01 -0600
committerRory Dudley2024-09-02 22:35:15 -0600
commit97ca3fa5197599ec28b19d5b2048f7c24e4c8bbc (patch)
tree7aa7c52a74c0bbf8afd154ce0bf7de04f11f5f85 /src/poem.rs
parent5c29835f70178e64daeae9b82111fe31376f6f35 (diff)
downloaddwarvish-97ca3fa5197599ec28b19d5b2048f7c24e4c8bbc.tar.gz
Refactor Verse::clause()
There is no reason to return an option for clause(), since it makes us perform a match twice, and since a blank vector is perfectly acceptable in all cases where the verse at hand may not have a clause. Signed-off-by: Rory Dudley <rory@netc.lu>
Diffstat (limited to 'src/poem.rs')
-rw-r--r--src/poem.rs14
1 files changed, 7 insertions, 7 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);
}