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.

4 Likes

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.