Skip to content

Commit 935f7a5

Browse files
committed
Change wording on comment on forget line
This is more specific as to why we need to call forget.
1 parent 324d58f commit 935f7a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/libcore/mem.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ pub use intrinsics::transmute;
8888
/// ptr::copy_nonoverlapping(&*y, x, 1);
8989
/// ptr::copy_nonoverlapping(&t, y, 1);
9090
///
91-
/// // y and t now point to the same thing, but we need to completely forget `t`
92-
/// // because it's no longer relevant.
91+
/// // y and t now point to the same thing, but we need to completely
92+
/// // forget `t` because we do not want to run the destructor for `T`
93+
/// // on its value, which is still owned somewhere outside this function.
9394
/// forget(t);
9495
/// }
9596
/// }
@@ -295,8 +296,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
295296
ptr::copy_nonoverlapping(&*y, x, 1);
296297
ptr::copy_nonoverlapping(&t, y, 1);
297298

298-
// y and t now point to the same thing, but we need to completely forget `t`
299-
// because it's no longer relevant.
299+
// y and t now point to the same thing, but we need to completely
300+
// forget `t` because we do not want to run the destructor for `T`
301+
// on its value, which is still owned somewhere outside this function.
300302
forget(t);
301303
}
302304
}

0 commit comments

Comments
 (0)