Hacker News new | ask | show | jobs
by bombela 1651 days ago
Note that the unsafe keyword of Rust unlock only few things. But that what makes it powerful.

unsafe mainly allows you to dereference pointers. References are guaranteed to be safe at all time, with an associated lifetime, while pointers can hold any possible memory address, valid or not (like in C++).

unsafe also let you promote a pointer to a reference by assigning a lifetime.

And finally, unsafe allows you to call functions themselves marked unsafe. One notable function is called transmute, and is very similar to how the the C style cast works in C++. It's the one that automatically selects between static_cast and reinterpret_cast depending on the context.