diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-20 22:25:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-20 22:25:27 +0100 |
commit | 70fe7a4515ebdc6222a6565cd4cd1c5fd0c77350 (patch) | |
tree | ecc5755941360a672c5ef1f6a040fb9f03c4b7d7 /crates/stdx | |
parent | ad131049c4cd1302af1a5616ff83d0e1f0cadea2 (diff) | |
parent | cdfe5a8be01dd7427db734f17c5ec0de7bbe6c80 (diff) |
Merge #8606
8606: fix: no more Registering progress handler for token rustAnalyzer/Ind… r=jonas-schievink a=matklad
…exing failed.
closes #8509
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/stdx')
-rw-r--r-- | crates/stdx/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index e3eb10915..857567a85 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -179,6 +179,18 @@ where | |||
179 | start..start + len | 179 | start..start + len |
180 | } | 180 | } |
181 | 181 | ||
182 | pub fn defer<F: FnOnce()>(f: F) -> impl Drop { | ||
183 | struct D<F: FnOnce()>(Option<F>); | ||
184 | impl<F: FnOnce()> Drop for D<F> { | ||
185 | fn drop(&mut self) { | ||
186 | if let Some(f) = self.0.take() { | ||
187 | f() | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | D(Some(f)) | ||
192 | } | ||
193 | |||
182 | #[repr(transparent)] | 194 | #[repr(transparent)] |
183 | pub struct JodChild(pub std::process::Child); | 195 | pub struct JodChild(pub std::process::Child); |
184 | 196 | ||