Skip to content

Commit

Permalink
Test ManuallyDrop::clone_from.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Jul 5, 2021
1 parent 543ab99 commit 3d20b2a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/core/tests/manually_drop.rs
Expand Up @@ -2,6 +2,7 @@ use core::mem::ManuallyDrop;

#[test]
fn smoke() {
#[derive(Clone)]
struct TypeWithDrop;
impl Drop for TypeWithDrop {
fn drop(&mut self) {
Expand All @@ -16,4 +17,11 @@ fn smoke() {
let x: Box<ManuallyDrop<[TypeWithDrop]>> =
Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop]));
drop(x);

// test clone and clone_from implementations
let mut x = ManuallyDrop::new(TypeWithDrop);
let y = x.clone();
x.clone_from(&y);
drop(x);
drop(y);
}

0 comments on commit 3d20b2a

Please sign in to comment.