Function std::ptr::from_mut

source ·
pub const fn from_mut<T>(r: &mut T) -> *mut Twhere
    T: ?Sized,
🔬This is a nightly-only experimental API. (ptr_from_ref #106116)
Expand description

将可变引用转换为裸指针。

这等同于 r as *mut T,但更安全一些,因为它永远不会默默地更改类型或可变性,尤其是在重构代码的情况下。