Skip to content

Commit

Permalink
add test to ensure that !Send and !Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang committed Feb 18, 2024
1 parent d5dfc65 commit fb7d426
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Send>(val: T) {}
/// impl_send(LinkNode::new(AtomicUsize::new(0)));
/// ```
///
/// Nor sync:
/// ```compile_fail,E0433
/// use std::sync::atomic::AtomicUsize;
///
/// fn impl_sync<T: Sync>(val: T) {}
/// impl_sync(LinkNode::new(AtomicUsize::new(0)));
/// ```
pub struct LinkNode<T>(Pin<Box<Inner<T>>>);

/// Pinned on heap for linking.
Expand Down

0 comments on commit fb7d426

Please sign in to comment.