refactor: use std::io::Error::other() instead of Error::new(ErrorKind::Other, e)

This commit is contained in:
Omar Sobh
2026-05-21 09:40:53 -07:00
parent dd3e1d0b11
commit 4b46719927
2 changed files with 9 additions and 10 deletions
+7 -7
View File
@@ -464,8 +464,8 @@ async fn background_writer(
Ok(indices) Ok(indices)
}) })
.await .await
.unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::new( .unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::other(
std::io::ErrorKind::Other, e, e,
)))); ))));
dirty = result.is_ok(); dirty = result.is_ok();
let _ = reply.send(result); let _ = reply.send(result);
@@ -498,8 +498,8 @@ async fn background_writer(
m.flush_wal() m.flush_wal()
}) })
.await .await
.unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::new( .unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::other(
std::io::ErrorKind::Other, e, e,
)))); ))));
if result.is_ok() { dirty = false; } if result.is_ok() { dirty = false; }
let _ = reply.send(result); let _ = reply.send(result);
@@ -515,8 +515,8 @@ async fn background_writer(
m.tick_session() m.tick_session()
}) })
.await .await
.unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::new( .unwrap_or_else(|e| Err(MemoryError::Io(std::io::Error::other(
std::io::ErrorKind::Other, e, e,
)))); ))));
if result.is_ok() { dirty = false; } if result.is_ok() { dirty = false; }
let _ = reply.send(result); let _ = reply.send(result);
@@ -549,7 +549,7 @@ async fn background_writer(
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
fn join_err(e: tokio::task::JoinError) -> MemoryError { fn join_err(e: tokio::task::JoinError) -> MemoryError {
MemoryError::Io(std::io::Error::new(std::io::ErrorKind::Other, e)) MemoryError::Io(std::io::Error::other(e))
} }
fn channel_gone() -> MemoryError { fn channel_gone() -> MemoryError {
+2 -3
View File
@@ -115,8 +115,8 @@ impl GpuSearchBackend {
} }
// If we don't have an accelerator but now above threshold, try init // If we don't have an accelerator but now above threshold, try init
if vectors.len() >= self.threshold { if vectors.len() >= self.threshold
if let Ok(mut accel) = clawhdf5_gpu::GpuAccelerator::new() { && let Ok(mut accel) = clawhdf5_gpu::GpuAccelerator::new() {
let flat: Vec<f32> = vectors.iter().flat_map(|v| v.iter().copied()).collect(); let flat: Vec<f32> = vectors.iter().flat_map(|v| v.iter().copied()).collect();
if accel.upload_vectors(&flat, self.dim).is_ok() if accel.upload_vectors(&flat, self.dim).is_ok()
&& accel.upload_norms(norms).is_ok() && accel.upload_norms(norms).is_ok()
@@ -125,7 +125,6 @@ impl GpuSearchBackend {
} }
} }
} }
}
#[cfg(not(feature = "gpu"))] #[cfg(not(feature = "gpu"))]
{ {