Skip to content

Commit d8a4813

Browse files
committed
Clippy lints
1 parent f483558 commit d8a4813

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed

spirit-daemonize/src/lib.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@
3030
//! daemon: DaemonOpts,
3131
//! }
3232
//!
33-
//! fn main() {
34-
//! Spirit::<Opts, Cfg>::new()
35-
//! .with(unsafe {
36-
//! spirit_daemonize::extension(|c: &Cfg, o: &Opts| {
37-
//! (c.daemon.clone(), o.daemon.clone())
38-
//! })
33+
//! Spirit::<Opts, Cfg>::new()
34+
//! .with(unsafe {
35+
//! spirit_daemonize::extension(|c: &Cfg, o: &Opts| {
36+
//! (c.daemon.clone(), o.daemon.clone())
3937
//! })
40-
//! .run(|_spirit| {
41-
//! // Possibly daemonized program goes here
42-
//! Ok(())
43-
//! });
44-
//! }
38+
//! })
39+
//! .run(|_spirit| {
40+
//! // Possibly daemonized program goes here
41+
//! Ok(())
42+
//! });
4543
//! ```
4644
//!
4745
//! # Added options

spirit-hyper/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ where
453453
type OutputResource = Activate<BS::OutputFut>;
454454
type OutputInstaller = FutureInstaller;
455455
fn installer(&mut self, _ii: Inst, _name: &'static str) -> Self::OutputInstaller {
456-
FutureInstaller::default()
456+
FutureInstaller
457457
}
458458
fn transform(
459459
&mut self,

spirit-log/src/background.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl Log for AsyncLogger {
342342
module_path: record.module_path().map(ToOwned::to_owned),
343343
msg: format!("{}", record.args()),
344344
target: record.target().to_owned(),
345-
thread: MY_THREAD_NAME.with(|n| Arc::clone(n)),
345+
thread: MY_THREAD_NAME.with(Arc::clone),
346346
};
347347
if self.mode == OverflowMode::Block {
348348
self.ch.send(i).expect("Logging thread disappeared");

spirit-tokio/src/handlers.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ where
3131
type OutputResource = Fut;
3232
type OutputInstaller = FutureInstaller;
3333
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
34-
FutureInstaller::default()
34+
FutureInstaller
3535
}
3636
fn transform(&mut self, r: R, cfg: &SF, name: &str) -> Result<Fut, AnyError> {
3737
trace!("Wrapping {} into a future", name);
@@ -146,7 +146,7 @@ where
146146
type OutputResource = Fut;
147147
type OutputInstaller = FutureInstaller;
148148
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
149-
FutureInstaller::default()
149+
FutureInstaller
150150
}
151151
fn transform(&mut self, r: R, _: &SF, name: &str) -> Result<Fut, AnyError> {
152152
trace!("Wrapping {} into a future", name);
@@ -185,7 +185,7 @@ where
185185
trace!("Got a new connection on {}", me.name);
186186
// Poking the borrow checker around the un-pinning, otherwise it is unhappy
187187
let fut = (me.f)(conn, me.cfg);
188-
tokio::spawn(async move { fut.await });
188+
tokio::spawn(fut);
189189
}
190190
Poll::Pending => return Poll::Pending,
191191
}
@@ -220,7 +220,7 @@ where
220220
type OutputResource = Acceptor<A, F, SF>;
221221
type OutputInstaller = FutureInstaller;
222222
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
223-
FutureInstaller::default()
223+
FutureInstaller
224224
}
225225
fn transform(
226226
&mut self,
@@ -263,7 +263,7 @@ where
263263
type OutputResource = Acceptor<A, FC, SF>;
264264
type OutputInstaller = FutureInstaller;
265265
fn installer(&mut self, _: II, _: &str) -> FutureInstaller {
266-
FutureInstaller::default()
266+
FutureInstaller
267267
}
268268
fn transform(
269269
&mut self,

src/fragment/pipeline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Error for MultiError {
7979
// There may actually be multiple causes. But we just stick with the first one for lack of
8080
// better way to pick.
8181
fn source(&self) -> Option<&(dyn Error + 'static)> {
82-
self.errors.get(0).map(|e| e.deref() as &dyn Error)
82+
self.errors.first().map(|e| e.deref() as &dyn Error)
8383
}
8484
}
8585

src/spirit.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,7 @@ where
586586
signals.add_signal(signal)?;
587587
let mut hooks = self.hooks.lock().unwrap_or_else(PoisonError::into_inner);
588588
if !hooks.terminated {
589-
hooks
590-
.sigs
591-
.entry(signal)
592-
.or_insert_with(Vec::new)
593-
.push(Box::new(hook));
589+
hooks.sigs.entry(signal).or_default().push(Box::new(hook));
594590
}
595591
Ok(self)
596592
}
@@ -833,10 +829,7 @@ impl<O, C> Extensible for Builder<O, C> {
833829
F: FnMut() + Send + 'static,
834830
{
835831
let mut hooks = self.sig_hooks;
836-
hooks
837-
.entry(signal)
838-
.or_insert_with(Vec::new)
839-
.push(Box::new(hook));
832+
hooks.entry(signal).or_default().push(Box::new(hook));
840833
Ok(Self {
841834
sig_hooks: hooks,
842835
..self

0 commit comments

Comments
 (0)