What is the difference between std::intrinsics::forget and std::mem::forget

What 's the difference between the two?
is there any running example to help to show the difference and help the understanding ?

It's right in the documentation.

TL;DR: intrinsics::forget() is a technical necessity to implement forget_unsized() and will be removed once by-value passing of dynamically-sized values is implemented.


From the source code of std::intrinsics::forget:

/// This exists solely for [`mem::forget_unsized`]; normal `forget` uses
/// `ManuallyDrop` instead.

Also note that std::intrinsics::forget isn't a stable function.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.