【发布时间】:2020-06-17 06:08:48
【问题描述】:
在documentation 中Unwindsafe 我们有:
&mutT 和&RefCell<T>等类型是不安全展开的示例。一般的想法是,任何可以在catch_unwind之间共享的可变状态默认情况下都不是安全的。这是因为在catch_unwind之外很容易看到损坏的不变量,因为数据只是照常访问。
按照这个逻辑,在我看来*mut T 不应该是Unwindsafe。但是it turns out that it is。这是为什么呢?
【问题讨论】:
-
我猜这是因为
*mut本身并没有不变量,所以没有“被破坏的不变量”可以观察。
标签: rust unsafe stack-unwinding raw-pointer