Make setup_ctrlc_handler return &mut Self

This commit is contained in:
Hirrolot 2022-02-03 12:48:02 +06:00
parent b11e5fdd19
commit d89eeb5847

View file

@ -238,7 +238,7 @@ where
/// [`shutdown`]: ShutdownToken::shutdown /// [`shutdown`]: ShutdownToken::shutdown
#[cfg(feature = "ctrlc_handler")] #[cfg(feature = "ctrlc_handler")]
#[cfg_attr(docsrs, doc(cfg(feature = "ctrlc_handler")))] #[cfg_attr(docsrs, doc(cfg(feature = "ctrlc_handler")))]
pub fn setup_ctrlc_handler(&mut self) { pub fn setup_ctrlc_handler(&mut self) -> &mut Self {
let state = Arc::clone(&self.state); let state = Arc::clone(&self.state);
tokio::spawn(async move { tokio::spawn(async move {
loop { loop {
@ -258,6 +258,8 @@ where
} }
} }
}); });
self
} }
/// Returns a shutdown token, which can later be used to shutdown /// Returns a shutdown token, which can later be used to shutdown