From 52210d1a8c2ab2668a6be5e04f19e3cb1f1a7aea Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 8 Jun 2022 20:48:31 +1000 Subject: [PATCH] Impl `Deref{Mut}` for `AutoAbortJoinHandle` Signed-off-by: Jiahao XU --- src/helpers.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/helpers.rs b/src/helpers.rs index 736cb74a..9cea2ef2 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,6 +1,7 @@ use std::{ fs, io::{self, stderr, stdin, Write}, + ops::{Deref, DerefMut}, path::{Path, PathBuf}, }; @@ -311,3 +312,17 @@ impl Drop for AutoAbortJoinHandle { self.0.abort(); } } + +impl Deref for AutoAbortJoinHandle { + type Target = task::JoinHandle; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for AutoAbortJoinHandle { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +}