I'm playing around with pointers and unsafe and I don't understand why this code segfaults
If I uncomment
std::mem::ManuallyDrop it works. The example for
String::from_raw_parts also uses it, but I don't understand why it's needed? The docs are saying that the ownership of the src pointer is transferred to the string.
Can anybody please explain what's going on here?
Also, why does it takes a
*mut pointer? Just a convention? I've noticed a lot of stdlib functions use
*mut even for reading.