From 3a747279da227d88d447cdcbcf6b6a0b885246de Mon Sep 17 00:00:00 2001 From: Mark Hildebrand Date: Fri, 21 Aug 2026 15:15:56 -0700 Subject: [PATCH] Make `UnalignedSlice` Send and Sync. --- diskann-vector/src/unaligned.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diskann-vector/src/unaligned.rs b/diskann-vector/src/unaligned.rs index 26dec240a3..6318c9c855 100644 --- a/diskann-vector/src/unaligned.rs +++ b/diskann-vector/src/unaligned.rs @@ -22,6 +22,14 @@ pub struct UnalignedSlice<'a, T> { _lifetime: PhantomData<&'a T>, } +/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be sent to other threads when `&T` is +/// send - implying the bound `T: Sync`. +unsafe impl Send for UnalignedSlice<'_, T> where T: Sync {} + +/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be shared with other threads when `&T` +/// is send, implying the bound `T: Sync`. +unsafe impl Sync for UnalignedSlice<'_, T> where T: Sync {} + impl<'a, T> UnalignedSlice<'a, T> { /// Construct a new [`UnalignedSlice`] over the region `[ptr, ptr.add(len))`. ///