From fb7d426919f8d3f33e82f75982d5b8dcaf171f71 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e2c608f..6f40c0f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,24 @@ 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,E0433 +/// use std::sync::atomic::AtomicUsize; +/// +/// fn impl_send(val: T) {} +/// impl_send(LinkNode::new(AtomicUsize::new(0))); +/// ``` +/// +/// Nor sync: +/// ```compile_fail,E0433 +/// 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.