*const T to *mut T?

Yes, the differences are:

  1. Methods in std usually take one or the other. This works as a lint and helps writing correct code.
  2. They differ in variance.

Safety-wise, it is not the kind of pointer that determines whether it is safe to mutate through the raw pointer. Rather, it is whether you originally got the raw pointer from an immutable reference that determines it.

9 Likes