File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 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 {
201201 /// };
202202 ///
203203 /// assert_eq!(*cloned, 123);
204+ /// # unsafe {<Rc<i32> as ErasablePtr>::unerase(erased)}; // drop it
204205 /// ```
205206 ///
206207 /// The main purpose of this function is to be able implement recursive types that would
@@ -215,7 +216,7 @@ pub unsafe trait ErasablePtr {
215216 Self : Sized ,
216217 F : FnOnce ( & Self ) -> T ,
217218 {
218- f ( & ManuallyDrop :: new ( & Self :: unerase ( * this) ) )
219+ f ( & ManuallyDrop :: new ( Self :: unerase ( * this) ) )
219220 }
220221
221222 /// 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() {
3434}
3535
3636#[ test]
37- fn withfn ( ) {
37+ fn with_fn ( ) {
3838 let boxed: Box < Big > = Default :: default ( ) ;
3939
4040 let erased: ErasedPtr = ErasablePtr :: erase ( boxed) ;
@@ -44,6 +44,9 @@ fn withfn() {
4444 assert_eq ! ( * bigbox, Default :: default ( ) ) ;
4545 } )
4646 }
47+
48+ // drop it, otherwise we would leak memory here
49+ unsafe { <Box < Big > as ErasablePtr >:: unerase ( erased) } ;
4750}
4851
4952#[ test]
You can’t perform that action at this time.
0 commit comments