In the documentation for Unwindsafe
we have:
Types such as
&mut
T and&RefCell<T>
are examples which are not unwind safe. The general idea is that any mutable state which can be shared acrosscatch_unwind
is not unwind safe by default. This is because it is very easy to witness a broken invariant outside ofcatch_unwind
as the data is simply accessed as usual.
Following this logic it seems to me that *mut T
should not be Unwindsafe
. But it turns out that it is. Why is that?
*mut T
being a raw pointer, it has no invariant whatsoever.
It can be null, point to invalid memory, it is Copy
, and you can have two of them pointing to the same area in memory.
There is nothing you can do mutably and safety with a *mut T
anyway, so it has no reason not to be Unwindsafe
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With