File tree 2 files changed +6
-2
lines changed
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ pub unsafe trait ErasablePtr {
201
201
/// };
202
202
///
203
203
/// assert_eq!(*cloned, 123);
204
+ /// # unsafe {<Rc<i32> as ErasablePtr>::unerase(erased)}; // drop it
204
205
/// ```
205
206
///
206
207
/// The main purpose of this function is to be able implement recursive types that would
@@ -215,7 +216,7 @@ pub unsafe trait ErasablePtr {
215
216
Self : Sized ,
216
217
F : FnOnce ( & Self ) -> T ,
217
218
{
218
- f ( & ManuallyDrop :: new ( & Self :: unerase ( * this) ) )
219
+ f ( & ManuallyDrop :: new ( Self :: unerase ( * this) ) )
219
220
}
220
221
221
222
/// Run a closure on a mutable borrow of the real pointer. Unlike the `Thin<T>` wrapper
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ fn thinning() {
34
34
}
35
35
36
36
#[ test]
37
- fn withfn ( ) {
37
+ fn with_fn ( ) {
38
38
let boxed: Box < Big > = Default :: default ( ) ;
39
39
40
40
let erased: ErasedPtr = ErasablePtr :: erase ( boxed) ;
@@ -44,6 +44,9 @@ fn withfn() {
44
44
assert_eq ! ( * bigbox, Default :: default ( ) ) ;
45
45
} )
46
46
}
47
+
48
+ // drop it, otherwise we would leak memory here
49
+ unsafe { <Box < Big > as ErasablePtr >:: unerase ( erased) } ;
47
50
}
48
51
49
52
#[ test]
You can’t perform that action at this time.
0 commit comments