From 90c6b2c319435dc398182ca7109b5e1574307f25 Mon Sep 17 00:00:00 2001 From: Congyu Date: Sun, 18 Feb 2024 12:13:45 +0800 Subject: [PATCH] add test to ensure that !Send and !Sync --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e2c608f..d72b969 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,26 @@ use std::{ }; /// Owned cell for data. +/// +/// The data structure is not thread safe. +/// It is not even safe to move to another thread. +/// (i.e., !Send). +/// ```compile_fail,E0277 +/// use cdlist::LinkNode; +/// use std::sync::atomic::AtomicUsize; +/// +/// fn impl_send(val: T) {} +/// impl_send(LinkNode::new(AtomicUsize::new(0))); +/// ``` +/// +/// Nor sync: +/// ```compile_fail,E0277 +/// use cdlist::LinkNode; +/// use std::sync::atomic::AtomicUsize; +/// +/// fn impl_sync(val: T) {} +/// impl_sync(LinkNode::new(AtomicUsize::new(0))); +/// ``` pub struct LinkNode(Pin>>); /// Pinned on heap for linking.