From 61eac020e5518ae4c68a6183d0058cbf3de391d6 Mon Sep 17 00:00:00 2001 From: Simon Walker Date: Tue, 10 Feb 2026 09:58:30 +0000 Subject: [PATCH] Implement Sync for ThreadsafeFitsFile Only Send was manually implemented. Since the inner Mutex ensures exclusive access, Sync is also safe and allows &ThreadsafeFitsFile to be shared between threads (e.g. with Arc or rayon parallel iterators). Co-Authored-By: Claude Opus 4.6 --- fitsio/src/threadsafe_fitsfile.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fitsio/src/threadsafe_fitsfile.rs b/fitsio/src/threadsafe_fitsfile.rs index a4b7262b..d002ba4c 100644 --- a/fitsio/src/threadsafe_fitsfile.rs +++ b/fitsio/src/threadsafe_fitsfile.rs @@ -24,6 +24,8 @@ pub struct ThreadsafeFitsFile(Arc>); // Safety: we explicitly wrap the type in an Arc::Mutex which is threadsafe. The Mutex ensures that // only one thread can be modifying the file at once. unsafe impl Send for ThreadsafeFitsFile {} +// Safety: the inner Mutex ensures exclusive access when shared across threads via &ThreadsafeFitsFile. +unsafe impl Sync for ThreadsafeFitsFile {} impl FitsFile { /**