@@ -42,13 +42,13 @@ use core::ptr;
42
42
/// See the [module-level documentation](self) for more.
43
43
#[ derive( Clone ) ]
44
44
#[ repr( transparent) ]
45
- pub struct WasmCell < T : ?Sized > {
46
- inner : * const Cell < T > ,
45
+ pub struct WasmCell < ' a , T : ?Sized > {
46
+ inner : & ' a Cell < T > ,
47
47
}
48
48
49
- unsafe impl < T : ?Sized > Send for WasmCell < T > where T : Send { }
49
+ unsafe impl < T : ?Sized > Send for WasmCell < ' _ , T > where T : Send { }
50
50
51
- unsafe impl < T : ?Sized > Sync for WasmCell < T > { }
51
+ unsafe impl < T : ?Sized > Sync for WasmCell < ' _ , T > { }
52
52
53
53
// impl<T: Copy> Clone for WasmCell<T> {
54
54
// #[inline]
@@ -67,16 +67,16 @@ unsafe impl<T: ?Sized> Sync for WasmCell<T> {}
67
67
// }
68
68
// }
69
69
70
- impl < T : PartialEq + Copy > PartialEq for WasmCell < T > {
70
+ impl < T : PartialEq + Copy > PartialEq for WasmCell < ' _ , T > {
71
71
#[ inline]
72
72
fn eq ( & self , other : & WasmCell < T > ) -> bool {
73
73
true
74
74
}
75
75
}
76
76
77
- impl < T : Eq + Copy > Eq for WasmCell < T > { }
77
+ impl < T : Eq + Copy > Eq for WasmCell < ' _ , T > { }
78
78
79
- impl < T : PartialOrd + Copy > PartialOrd for WasmCell < T > {
79
+ impl < T : PartialOrd + Copy > PartialOrd for WasmCell < ' _ , T > {
80
80
#[ inline]
81
81
fn partial_cmp ( & self , other : & WasmCell < T > ) -> Option < Ordering > {
82
82
self . inner . partial_cmp ( & other. inner )
@@ -103,7 +103,7 @@ impl<T: PartialOrd + Copy> PartialOrd for WasmCell<T> {
103
103
}
104
104
}
105
105
106
- impl < T : Ord + Copy > Ord for WasmCell < T > {
106
+ impl < T : Ord + Copy > Ord for WasmCell < ' _ , T > {
107
107
#[ inline]
108
108
fn cmp ( & self , other : & WasmCell < T > ) -> Ordering {
109
109
self . get ( ) . cmp ( & other. get ( ) )
@@ -117,7 +117,7 @@ impl<T: Ord + Copy> Ord for WasmCell<T> {
117
117
// }
118
118
// }
119
119
120
- impl < T > WasmCell < T > {
120
+ impl < ' a , T > WasmCell < ' a , T > {
121
121
/// Creates a new `WasmCell` containing the given value.
122
122
///
123
123
/// # Examples
@@ -128,7 +128,7 @@ impl<T> WasmCell<T> {
128
128
/// let c = WasmCell::new(5);
129
129
/// ```
130
130
#[ inline]
131
- pub const fn new ( cell : * const Cell < T > ) -> WasmCell < T > {
131
+ pub const fn new ( cell : & ' a Cell < T > ) -> WasmCell < ' a , T > {
132
132
WasmCell {
133
133
inner : cell,
134
134
}
@@ -202,7 +202,7 @@ impl<T> WasmCell<T> {
202
202
// }
203
203
}
204
204
205
- impl < T : Copy > WasmCell < T > {
205
+ impl < T : Copy > WasmCell < ' _ , T > {
206
206
/// Returns a copy of the contained value.
207
207
///
208
208
/// # Examples
@@ -216,11 +216,17 @@ impl<T: Copy> WasmCell<T> {
216
216
/// ```
217
217
#[ inline]
218
218
pub fn get ( & self ) -> T {
219
- unsafe { ( * self . inner ) . get ( ) }
219
+ self . inner . get ( )
220
+ }
221
+
222
+ /// Get an unsafe mutable pointer to the inner item
223
+ /// in the Cell.
224
+ pub unsafe fn get_mut ( & self ) -> & mut T {
225
+ & mut * self . inner . as_ptr ( )
220
226
}
221
227
}
222
228
223
- impl < T : Sized > WasmCell < T > {
229
+ impl < T : Sized > WasmCell < ' _ , T > {
224
230
/// Sets the contained value.
225
231
///
226
232
/// # Examples
@@ -234,6 +240,6 @@ impl<T: Sized> WasmCell<T> {
234
240
/// ```
235
241
#[ inline]
236
242
pub fn set ( & self , val : T ) {
237
- unsafe { ( * self . inner ) . set ( val) } ;
243
+ self . inner . set ( val) ;
238
244
}
239
245
}
0 commit comments