Skip to content

Commit 5ac7a90

Browse files
committed
Implement an alternative solution for the variance issue not involving Mutex
1 parent ce09654 commit 5ac7a90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
//! }
7373
//! ```
7474
75-
use std::sync::Mutex;
7675
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
7776
use std::marker::PhantomData;
7877
use std::fmt;
@@ -82,7 +81,8 @@ use std::default::Default;
8281
#[repr(C)]
8382
pub struct AtomicRef<'a, T: 'a> {
8483
data: AtomicUsize,
85-
_marker: PhantomData<Mutex<&'a T>>,
84+
// Make `AtomicRef` invariant over `'a` and `T`
85+
_marker: PhantomData<&'a mut &'a mut T>,
8686
}
8787

8888
/// You will probably never need to use this type. It exists mostly for internal

0 commit comments

Comments
 (0)