shadow_shim_helper_rs/util/
mod.rs1pub mod time;
2
3pub trait NoTypeInference {
19 type This;
20}
21
22impl<T> NoTypeInference for T {
23 type This = T;
24}
25
26pub struct SyncSendPointer<T>(*mut T);
29
30impl<T> Copy for SyncSendPointer<T> {}
34impl<T> Clone for SyncSendPointer<T> {
35 fn clone(&self) -> Self {
36 *self
37 }
38}
39
40unsafe impl<T> Send for SyncSendPointer<T> {}
41unsafe impl<T> Sync for SyncSendPointer<T> {}
42
43impl<T> SyncSendPointer<T> {
44 pub unsafe fn new(ptr: *mut T) -> Self {
49 Self(ptr)
50 }
51
52 pub fn ptr(&self) -> *mut T {
53 self.0
54 }
55}
56
57impl<T> core::fmt::Debug for SyncSendPointer<T> {
58 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59 write!(f, "{:?}", self.ptr())
60 }
61}
62
63impl<T> PartialEq for SyncSendPointer<T> {
64 fn eq(&self, other: &Self) -> bool {
65 core::ptr::eq(self.ptr(), other.ptr())
66 }
67}
68
69impl<T> Eq for SyncSendPointer<T> {}
70
71pub struct SendPointer<T>(*mut T);
74
75impl<T> Copy for SendPointer<T> {}
79impl<T> Clone for SendPointer<T> {
80 fn clone(&self) -> Self {
81 *self
82 }
83}
84
85unsafe impl<T> Send for SendPointer<T> {}
86
87impl<T> SendPointer<T> {
88 pub unsafe fn new(ptr: *mut T) -> Self {
93 Self(ptr)
94 }
95
96 pub fn ptr(&self) -> *mut T {
97 self.0
98 }
99}
100
101impl<T> core::fmt::Debug for SendPointer<T> {
102 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
103 write!(f, "{:?}", self.ptr())
104 }
105}
106
107impl<T> PartialEq for SendPointer<T> {
108 fn eq(&self, other: &Self) -> bool {
109 core::ptr::eq(self.ptr(), other.ptr())
110 }
111}
112
113impl<T> Eq for SendPointer<T> {}
114
115pub struct DebugFormatter<F>(pub F)
117where
118 F: Fn(&mut core::fmt::Formatter<'_>) -> core::fmt::Result;
119
120impl<F> core::fmt::Debug for DebugFormatter<F>
121where
122 F: Fn(&mut core::fmt::Formatter<'_>) -> core::fmt::Result,
123{
124 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
125 self.0(f)
126 }
127}