aboutsummaryrefslogtreecommitdiff
path: root/crates/stdx
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-04-20 20:54:05 +0100
committerAleksey Kladov <[email protected]>2021-04-20 20:54:05 +0100
commitcdfe5a8be01dd7427db734f17c5ec0de7bbe6c80 (patch)
treeecc5755941360a672c5ef1f6a040fb9f03c4b7d7 /crates/stdx
parentad131049c4cd1302af1a5616ff83d0e1f0cadea2 (diff)
fix: no more Registering progress handler for token rustAnalyzer/Indexing failed.
Diffstat (limited to 'crates/stdx')
-rw-r--r--crates/stdx/src/lib.rs12
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
182pub 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)]
183pub struct JodChild(pub std::process::Child); 195pub struct JodChild(pub std::process::Child);
184 196