diff --git a/crossbeam-channel/src/channel.rs b/crossbeam-channel/src/channel.rs index 800fe6352..7871bcb70 100644 --- a/crossbeam-channel/src/channel.rs +++ b/crossbeam-channel/src/channel.rs @@ -160,7 +160,7 @@ pub fn bounded(cap: usize) -> (Sender, Receiver) { /// let ms = |ms| Duration::from_millis(ms); /// /// // Returns `true` if `a` and `b` are very close `Instant`s. -/// let eq = |a, b| a + ms(50) > b && b + ms(50) > a; +/// let eq = |a, b| a + ms(60) > b && b + ms(60) > a; /// /// let start = Instant::now(); /// let r = after(ms(100)); diff --git a/crossbeam-epoch/src/atomic.rs b/crossbeam-epoch/src/atomic.rs index f5e1c1611..b33a8ac86 100644 --- a/crossbeam-epoch/src/atomic.rs +++ b/crossbeam-epoch/src/atomic.rs @@ -891,8 +891,9 @@ impl From<*const T> for Atomic { } /// A trait for either `Owned` or `Shared` pointers. -// TODO: seal this trait https://github.com/crossbeam-rs/crossbeam/issues/620 -pub trait Pointer { +/// +/// This trait is sealed and cannot be implemented for types outside of `crossbeam-epoch`. +pub trait Pointer: crate::sealed::Sealed { /// Returns the machine representation of the pointer. fn into_ptr(self) -> *mut (); @@ -916,6 +917,7 @@ pub struct Owned { _marker: PhantomData>, } +impl crate::sealed::Sealed for Owned {} impl Pointer for Owned { #[inline] fn into_ptr(self) -> *mut () { @@ -1176,6 +1178,7 @@ impl Clone for Shared<'_, T> { impl Copy for Shared<'_, T> {} +impl crate::sealed::Sealed for Shared<'_, T> {} impl Pointer for Shared<'_, T> { #[inline] fn into_ptr(self) -> *mut () { diff --git a/crossbeam-epoch/src/lib.rs b/crossbeam-epoch/src/lib.rs index 80cc27305..16a1f437c 100644 --- a/crossbeam-epoch/src/lib.rs +++ b/crossbeam-epoch/src/lib.rs @@ -156,6 +156,10 @@ cfg_if! { }; pub use self::collector::{Collector, LocalHandle}; pub use self::guard::{unprotected, Guard}; + + mod sealed { + pub trait Sealed {} + } } }