summaryrefslogtreecommitdiffstats
path: root/src/poem/elements
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/elements
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/elements')
-rw-r--r--src/poem/elements/verse.rs8
-rw-r--r--src/poem/elements/verse/logic.rs2
2 files changed, 5 insertions, 5 deletions
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 {