diff --git a/src/lib.rs b/src/lib.rs index 43c670f..16eadb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -362,6 +362,7 @@ impl fmt::Debug for ThreadLocal { impl UnwindSafe for ThreadLocal {} /// Iterator over the contents of a `ThreadLocal`. +#[derive(Debug)] pub struct Iter<'a, T: Send + Sync> { thread_local: &'a ThreadLocal, yielded: usize, @@ -450,6 +451,9 @@ impl Iterator for RawIterMut { } } +unsafe impl Send for RawIterMut {} +unsafe impl Sync for RawIterMut {} + /// Mutable iterator over the contents of a `ThreadLocal`. pub struct IterMut<'a, T: Send> { raw: RawIterMut, @@ -471,6 +475,19 @@ impl<'a, T: Send> Iterator for IterMut<'a, T> { } impl ExactSizeIterator for IterMut<'_, T> {} +impl FusedIterator for IterMut<'_, T> {} + +// The Debug bound is technically unnecessary but makes the API more consistent and future-proof. +impl fmt::Debug for IterMut<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("IterMut") + .field("remaining", &self.raw.remaining) + .field("bucket", &self.raw.bucket) + .field("bucket_size", &self.raw.bucket_size) + .field("index", &self.raw.index) + .finish() + } +} /// An iterator that moves out of a `ThreadLocal`. pub struct IntoIter { @@ -493,6 +510,19 @@ impl Iterator for IntoIter { } impl ExactSizeIterator for IntoIter {} +impl FusedIterator for IntoIter {} + +// The Debug bound is technically unnecessary but makes the API more consistent and future-proof. +impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("IntoIter") + .field("remaining", &self.raw.remaining) + .field("bucket", &self.raw.bucket) + .field("bucket_size", &self.raw.bucket_size) + .field("index", &self.raw.index) + .finish() + } +} fn allocate_bucket(size: usize) -> *mut Entry { Box::into_raw(