Skip to content

Commit

Permalink
Fix clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Jan 17, 2025
1 parent 70f06d5 commit 0154620
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/subcommand/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/from_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/torrent/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
6 changes: 3 additions & 3 deletions src/xor_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::common::*;

pub(crate) fn xor_args<T: Clone>(
a_name: &str,
a: &Option<T>,
a: Option<&T>,
b_name: &str,
b: &Option<T>,
b: Option<&T>,
) -> Result<T> {
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",
))
Expand Down

0 comments on commit 0154620

Please sign in to comment.