@@ -102,7 +102,7 @@ pub struct Document {
102 language_server: Option<Arc<helix_lsp::Client>>,
102 language_server: Option<Arc<helix_lsp::Client>>,
105−use std::fmt;
105+use std::{fmt, mem};
106impl fmt::Debug for Document {
106impl fmt::Debug for Document {
107 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
108 f.debug_struct("Document")
108 f.debug_struct("Document")
@@ -301,20 +301,13 @@ pub async fn to_writer<'a, W: tokio::io::AsyncWriteExt + Unpin + ?Sized>(
304−/// Like std::mem::replace() except it allows the replacement value to be mapped from the
306−fn take_with<T, F>(mut_ref: &mut T, closure: F)
304+fn take_with<T, F>(mut_ref: &mut T, f: F)
308 F: FnOnce(T) -> T,
307 F: FnOnce(T) -> T,
310− use std::{panic, ptr};
313− let old_t = ptr::read(mut_ref);
309+ let t = mem::take(mut_ref);
314− let new_t = panic::catch_unwind(panic::AssertUnwindSafe(|| closure(old_t)))
310+ let _ = mem::replace(mut_ref, f(t));
315− .unwrap_or_else(|_| ::std::process::abort());
316− ptr::write(mut_ref, new_t);
320use helix_lsp::lsp;
313use helix_lsp::lsp;