mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 20:50:03 +00:00
Impl new convenient fn AutoAbortJoinHandle::spawn
As a shortcut to `AutoAbortJoinHandle::new(tokio::spawn(...))` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
64e948f941
commit
2103dea3ac
1 changed files with 12 additions and 0 deletions
|
@ -16,6 +16,18 @@ impl<T> AutoAbortJoinHandle<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> AutoAbortJoinHandle<T>
|
||||||
|
where
|
||||||
|
T: Send + 'static,
|
||||||
|
{
|
||||||
|
pub fn spawn<F>(future: F) -> Self
|
||||||
|
where
|
||||||
|
F: Future<Output = T> + Send + 'static,
|
||||||
|
{
|
||||||
|
Self(tokio::spawn(future))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Drop for AutoAbortJoinHandle<T> {
|
impl<T> Drop for AutoAbortJoinHandle<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.0.abort();
|
self.0.abort();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue