1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use super::{Guard, RefCnt};
mod sealed {
pub trait Sealed {}
}
use self::sealed::Sealed;
pub trait AsRaw<T>: Sealed {
fn as_raw(&self) -> *mut T;
}
impl<'a, T: RefCnt> Sealed for &'a T {}
impl<'a, T: RefCnt> AsRaw<T::Base> for &'a T {
fn as_raw(&self) -> *mut T::Base {
T::as_ptr(self)
}
}
impl<'a, T: RefCnt> Sealed for &'a Guard<T> {}
impl<'a, T: RefCnt> AsRaw<T::Base> for &'a Guard<T> {
fn as_raw(&self) -> *mut T::Base {
T::as_ptr(&self)
}
}
impl<'a, T: RefCnt> Sealed for Guard<T> {}
impl<'a, T: RefCnt> AsRaw<T::Base> for Guard<T> {
fn as_raw(&self) -> *mut T::Base {
T::as_ptr(&self)
}
}
impl<T> Sealed for *mut T {}
impl<T> AsRaw<T> for *mut T {
fn as_raw(&self) -> *mut T {
*self
}
}
impl<T> Sealed for *const T {}
impl<T> AsRaw<T> for *const T {
fn as_raw(&self) -> *mut T {
*self as *mut T
}
}