Intermediate Rust
Q87 / 100

What does the std::mem::forget function do?

Correct! Well done.

Incorrect.

The correct answer is B) Consumes a value without running its destructor, leaking any resources it owns

B

Correct Answer

Consumes a value without running its destructor, leaking any resources it owns

Explanation

mem::forget(value) is safe but leaks resources. Used when transferring ownership to C code (ManuallyDrop is preferred), or implementing FFI handshakes.

Progress
87/100