diff options
Diffstat (limited to 'crates/stdx/src')
-rw-r--r-- | crates/stdx/src/lib.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 374ed5910..5332edb09 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | //! Missing batteries for standard libraries. | 1 | //! Missing batteries for standard libraries. |
2 | use std::time::Instant; | 2 | use std::{ops, process, time::Instant}; |
3 | 3 | ||
4 | mod macros; | 4 | mod macros; |
5 | pub mod panic_context; | 5 | pub mod panic_context; |
@@ -147,6 +147,27 @@ where | |||
147 | left | 147 | left |
148 | } | 148 | } |
149 | 149 | ||
150 | pub struct JodChild(pub process::Child); | ||
151 | |||
152 | impl ops::Deref for JodChild { | ||
153 | type Target = process::Child; | ||
154 | fn deref(&self) -> &process::Child { | ||
155 | &self.0 | ||
156 | } | ||
157 | } | ||
158 | |||
159 | impl ops::DerefMut for JodChild { | ||
160 | fn deref_mut(&mut self) -> &mut process::Child { | ||
161 | &mut self.0 | ||
162 | } | ||
163 | } | ||
164 | |||
165 | impl Drop for JodChild { | ||
166 | fn drop(&mut self) { | ||
167 | let _ = self.0.kill(); | ||
168 | } | ||
169 | } | ||
170 | |||
150 | #[cfg(test)] | 171 | #[cfg(test)] |
151 | mod tests { | 172 | mod tests { |
152 | use super::*; | 173 | use super::*; |