Skip to content

Commit

Permalink
refactor: with clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtoo committed Jan 7, 2024
1 parent ee356c3 commit f024ffb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
29 changes: 13 additions & 16 deletions src/app/components/cmd_not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@ impl<T: 'static, C: super::Component<Output = anyhow::Result<T>> + Send + Sync>
async fn handle(&self) -> Self::Output {
let result = self.inner.handle().await;

match &result {
Err(_) => {
if self.command.is_empty() {
eprintln!("cx: no command entered")
} else {
eprintln!(
"cx: command not found '{}'",
self.command
.split(" ")
.collect::<Vec<_>>()
.get(0)
.unwrap_or(&"")
)
}
if let Err(_) = &result {
if self.command.is_empty() {
eprintln!("cx: no command entered")
} else {
eprintln!(
"cx: command not found '{}'",
self.command
.split(' ')
.collect::<Vec<_>>()
.first()
.unwrap_or(&"")
)
}
_ => (),
};
}

result
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> From<SharedParams<'a, PrintableCmdNotFound<CmdExecutor<'a>>>>
Self {
inner: WaitSec {
sec: state.interval,
sleeper: state.sleeper.clone(),
sleeper: state.sleeper,
},
command: state.command,
interval: state.interval,
Expand Down
4 changes: 2 additions & 2 deletions src/app/supervise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> From<SharedParams<'a, PrintableCmdNotFound<CmdExecutor<'a>>>>
Self {
inner: WaitSec {
sec: state.interval,
sleeper: state.sleeper.clone(),
sleeper: state.sleeper,
},
command: state.command,
interval: state.interval,
Expand All @@ -90,7 +90,7 @@ impl<'a> From<SharedParams<'a, WaitSec<'a>>>
command: state.command.to_owned(),
inner: CmdExecutor {
command: state.command.to_owned(),
executor: &*state.executor,
executor: state.executor,
},
},
command: state.command,
Expand Down
2 changes: 1 addition & 1 deletion src/io/tokio_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl PipedCmdExecutor {

let options = elements.drain(1..).collect::<Vec<_>>();

let program = match elements.get(0) {
let program = match elements.first() {
Some(_) => elements.remove(0),
None => String::new(),
};
Expand Down

0 comments on commit f024ffb

Please sign in to comment.