Skip to content

Commit

Permalink
Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
vorner committed Mar 9, 2024
1 parent f483558 commit d8a4813
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 28 deletions.
20 changes: 9 additions & 11 deletions spirit-daemonize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
//! daemon: DaemonOpts,
//! }
//!
//! fn main() {
//! Spirit::<Opts, Cfg>::new()
//! .with(unsafe {
//! spirit_daemonize::extension(|c: &Cfg, o: &Opts| {
//! (c.daemon.clone(), o.daemon.clone())
//! })
//! Spirit::<Opts, Cfg>::new()
//! .with(unsafe {
//! spirit_daemonize::extension(|c: &Cfg, o: &Opts| {
//! (c.daemon.clone(), o.daemon.clone())
//! })
//! .run(|_spirit| {
//! // Possibly daemonized program goes here
//! Ok(())
//! });
//! }
//! })
//! .run(|_spirit| {
//! // Possibly daemonized program goes here
//! Ok(())
//! });
//! ```
//!
//! # Added options
Expand Down
2 changes: 1 addition & 1 deletion spirit-hyper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ where
type OutputResource = Activate<BS::OutputFut>;
type OutputInstaller = FutureInstaller;
fn installer(&mut self, _ii: Inst, _name: &'static str) -> Self::OutputInstaller {
FutureInstaller::default()
FutureInstaller
}
fn transform(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion spirit-log/src/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Log for AsyncLogger {
module_path: record.module_path().map(ToOwned::to_owned),
msg: format!("{}", record.args()),
target: record.target().to_owned(),
thread: MY_THREAD_NAME.with(|n| Arc::clone(n)),
thread: MY_THREAD_NAME.with(Arc::clone),
};
if self.mode == OverflowMode::Block {
self.ch.send(i).expect("Logging thread disappeared");
Expand Down
10 changes: 5 additions & 5 deletions spirit-tokio/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
type OutputResource = Fut;
type OutputInstaller = FutureInstaller;
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
FutureInstaller::default()
FutureInstaller
}
fn transform(&mut self, r: R, cfg: &SF, name: &str) -> Result<Fut, AnyError> {
trace!("Wrapping {} into a future", name);
Expand Down Expand Up @@ -146,7 +146,7 @@ where
type OutputResource = Fut;
type OutputInstaller = FutureInstaller;
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
FutureInstaller::default()
FutureInstaller
}
fn transform(&mut self, r: R, _: &SF, name: &str) -> Result<Fut, AnyError> {
trace!("Wrapping {} into a future", name);
Expand Down Expand Up @@ -185,7 +185,7 @@ where
trace!("Got a new connection on {}", me.name);
// Poking the borrow checker around the un-pinning, otherwise it is unhappy
let fut = (me.f)(conn, me.cfg);
tokio::spawn(async move { fut.await });
tokio::spawn(fut);
}
Poll::Pending => return Poll::Pending,
}
Expand Down Expand Up @@ -220,7 +220,7 @@ where
type OutputResource = Acceptor<A, F, SF>;
type OutputInstaller = FutureInstaller;
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
FutureInstaller::default()
FutureInstaller
}
fn transform(
&mut self,
Expand Down Expand Up @@ -263,7 +263,7 @@ where
type OutputResource = Acceptor<A, FC, SF>;
type OutputInstaller = FutureInstaller;
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
FutureInstaller::default()
FutureInstaller
}
fn transform(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion src/fragment/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Error for MultiError {
// There may actually be multiple causes. But we just stick with the first one for lack of
// better way to pick.
fn source(&self) -> Option<&(dyn Error + 'static)> {
self.errors.get(0).map(|e| e.deref() as &dyn Error)
self.errors.first().map(|e| e.deref() as &dyn Error)
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/spirit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,7 @@ where
signals.add_signal(signal)?;
let mut hooks = self.hooks.lock().unwrap_or_else(PoisonError::into_inner);
if !hooks.terminated {
hooks
.sigs
.entry(signal)
.or_insert_with(Vec::new)
.push(Box::new(hook));
hooks.sigs.entry(signal).or_default().push(Box::new(hook));
}
Ok(self)
}
Expand Down Expand Up @@ -833,10 +829,7 @@ impl<O, C> Extensible for Builder<O, C> {
F: FnMut() + Send + 'static,
{
let mut hooks = self.sig_hooks;
hooks
.entry(signal)
.or_insert_with(Vec::new)
.push(Box::new(hook));
hooks.entry(signal).or_default().push(Box::new(hook));
Ok(Self {
sig_hooks: hooks,
..self
Expand Down

0 comments on commit d8a4813

Please sign in to comment.