【发布时间】:2019-12-20 14:24:30
【问题描述】:
据我了解,在 Rust 中创建空指针的标准(唯一?)方法是 std::ptr::null。
但是,该函数声明如下。
pub const fn null<T>() -> *const T
在此声明中,T 被隐式假定为具有固定大小(否则为T: ?Sized)。因此,无法将此函数与 *const str 或 *const [u32] 一起使用。 test it in the playground
排除未调整大小的类型是否有充分的理由?想要创建一个空的*const str 有什么问题?
【问题讨论】: