diff --git a/src/subcommand/completions.rs b/src/subcommand/completions.rs index a6071b9..e750950 100644 --- a/src/subcommand/completions.rs +++ b/src/subcommand/completions.rs @@ -49,9 +49,9 @@ impl Completions { if self.shell_flag.is_some() || self.shell_positional.is_some() { let shell = xor_args( "shell_flag", - &self.shell_flag, + self.shell_flag.as_ref(), "shell_positional", - &self.shell_positional, + self.shell_positional.as_ref(), )?; if let Some(dir) = self.dir { diff --git a/src/subcommand/torrent/announce.rs b/src/subcommand/torrent/announce.rs index 77fedf7..2da48db 100644 --- a/src/subcommand/torrent/announce.rs +++ b/src/subcommand/torrent/announce.rs @@ -40,9 +40,9 @@ impl Announce { pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> { let target = xor_args( "input_flag", - &self.input_flag, + self.input_flag.as_ref(), "input_positional", - &self.input_positional, + self.input_positional.as_ref(), )?; let input = env.read(target)?; diff --git a/src/subcommand/torrent/create.rs b/src/subcommand/torrent/create.rs index a505af7..0b9b0d0 100644 --- a/src/subcommand/torrent/create.rs +++ b/src/subcommand/torrent/create.rs @@ -280,9 +280,9 @@ impl Create { pub(crate) fn run(self, env: &mut Env, options: &Options) -> Result<(), Error> { let input = xor_args( "input_positional", - &self.input_positional, + self.input_positional.as_ref(), "input_flag", - &self.input_flag, + self.input_flag.as_ref(), )?; let mut linter = Linter::new(); diff --git a/src/subcommand/torrent/dump.rs b/src/subcommand/torrent/dump.rs index b302866..5f9e808 100644 --- a/src/subcommand/torrent/dump.rs +++ b/src/subcommand/torrent/dump.rs @@ -85,9 +85,9 @@ impl Dump { pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> { let target = xor_args( "input_positional", - &self.input_positional, + self.input_positional.as_ref(), "input_flag", - &self.input_flag, + self.input_flag.as_ref(), )?; let input = env.read(target.clone())?; diff --git a/src/subcommand/torrent/from_link.rs b/src/subcommand/torrent/from_link.rs index 209d038..b3dd5e6 100644 --- a/src/subcommand/torrent/from_link.rs +++ b/src/subcommand/torrent/from_link.rs @@ -48,9 +48,9 @@ impl FromLink { pub(crate) fn run(self, env: &mut Env, options: &Options) -> Result<()> { let link = xor_args( "input_flag", - &self.input_flag, + self.input_flag.as_ref(), "input_positional", - &self.input_positional, + self.input_positional.as_ref(), )?; let infohash = link.infohash; diff --git a/src/subcommand/torrent/link.rs b/src/subcommand/torrent/link.rs index 8130687..1114fd8 100644 --- a/src/subcommand/torrent/link.rs +++ b/src/subcommand/torrent/link.rs @@ -63,9 +63,9 @@ impl Link { pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> { let input = xor_args( "input_flag", - &self.input_flag, + self.input_flag.as_ref(), "input_positional", - &self.input_positional, + self.input_positional.as_ref(), )?; let input = env.read(input)?; diff --git a/src/subcommand/torrent/show.rs b/src/subcommand/torrent/show.rs index e4216e4..851562c 100644 --- a/src/subcommand/torrent/show.rs +++ b/src/subcommand/torrent/show.rs @@ -53,9 +53,9 @@ impl Show { pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> { let target = xor_args( "input_flag", - &self.input_flag, + self.input_flag.as_ref(), "input_positional", - &self.input_positional, + self.input_positional.as_ref(), )?; let input = env.read(target)?; diff --git a/src/subcommand/torrent/verify.rs b/src/subcommand/torrent/verify.rs index 98339d0..fc61a64 100644 --- a/src/subcommand/torrent/verify.rs +++ b/src/subcommand/torrent/verify.rs @@ -65,9 +65,9 @@ impl Verify { pub(crate) fn run(self, env: &mut Env, options: &Options) -> Result<(), Error> { let target = xor_args( "input_positional", - &self.input_positional, + self.input_positional.as_ref(), "input_flag", - &self.input_flag, + self.input_flag.as_ref(), )?; VerifyStep::Loading { metainfo: &target }.print(env)?; diff --git a/src/xor_args.rs b/src/xor_args.rs index d97a51d..1ba5449 100644 --- a/src/xor_args.rs +++ b/src/xor_args.rs @@ -2,11 +2,11 @@ use crate::common::*; pub(crate) fn xor_args( a_name: &str, - a: &Option, + a: Option<&T>, b_name: &str, - b: &Option, + b: Option<&T>, ) -> Result { - let target = a.as_ref().xor(b.as_ref()).ok_or_else(|| { + let target = a.xor(b).ok_or_else(|| { Error::internal(format!( "Expected exactly one of the arguments `{a_name}` or `{b_name}` to be set", ))