Skip to content

Commit

Permalink
improve doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang committed Mar 3, 2024
1 parent b409a1d commit 248e2eb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ use std::{
///
/// The data structure is not thread safe.
/// It is not even safe to move to another thread.
/// (i.e., !Send).
/// (!Send and !Sync for whatever type of T).
///
/// Not sync.
/// ```compile_fail,E0277
/// use cdlist::LinkNode;
/// use std::sync::atomic::AtomicUsize;
///
/// fn impl_send<T: Send>(val: T) {}
/// fn impl_sync<T: Sync>(val: T) {}
/// /// should not compile
/// impl_send(LinkNode::new(AtomicUsize::new(0)));
/// impl_sync(LinkNode::new(AtomicUsize::new(0)));
/// ```
///
/// Nor sync:
/// Not send.
/// ```compile_fail,E0277
/// use cdlist::LinkNode;
/// use std::sync::atomic::AtomicUsize;
///
/// fn impl_sync<T: Sync>(val: T) {}
/// fn impl_send<T: Send>(val: T) {}
/// /// should not compile
/// impl_sync(LinkNode::new(AtomicUsize::new(0)));
/// impl_send(LinkNode::new(AtomicUsize::new(0)));
/// ```
pub struct LinkNode<T>(Pin<Box<Inner<T>>>);

Expand Down

0 comments on commit 248e2eb

Please sign in to comment.