From 306ad5717c0c7d0a078ff13b68acc07717e41035 Mon Sep 17 00:00:00 2001 From: mrshmllow Date: Thu, 8 Sep 2022 21:13:56 +1000 Subject: [PATCH] change unwrap_or to unwrap_or_else --- src/internal/commands.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/internal/commands.rs b/src/internal/commands.rs index 783a0a0..f06c604 100644 --- a/src/internal/commands.rs +++ b/src/internal/commands.rs @@ -51,7 +51,12 @@ impl ShellCommand { } pub fn sudo() -> Self { - Self::new(config::read().bin.sudo.unwrap_or("sudo".to_string())) + Self::new( + config::read() + .bin + .sudo + .unwrap_or_else(|| "sudo".to_string()), + ) } pub fn rm() -> Self { @@ -146,7 +151,12 @@ impl ShellCommand { (Stdio::inherit(), Stdio::inherit()) }; let mut command = if self.elevated { - let mut cmd = Command::new(config::read().bin.sudo.unwrap_or("sudo".to_string())); + let mut cmd = Command::new( + config::read() + .bin + .sudo + .unwrap_or_else(|| "sudo".to_string()), + ); cmd.arg(self.command); cmd