| 1 | use std::marker::PhantomData; |
|---|---|
| 2 | use std::ops::Deref; |
| 3 | |
| 4 | pub struct Unique<T> { |
| 5 | contents: *mut T, |
| 6 | _marker: PhantomData<T>, |
| 7 | } |
| 8 | |
| 9 | impl<T> Deref for Unique<T> { |
| 10 | type Target = *mut T; |
| 11 | fn deref(&self) -> &Self::Target { |
| 12 | &self.contents |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | impl<T> Unique<T> { |
| 17 | pub unsafe fn new(ptr: *mut T) -> Self { |
| 18 | Unique { |
| 19 | contents: ptr, |
| 20 | _marker: PhantomData, |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 |
