Function std::intrinsics::offset[][src]

#[must_use = "returns a new pointer rather than modifying its argument"]
pub const unsafe extern "rust-intrinsic" fn offset<T>(
    dst: *const T,
    offset: isize
) -> *const T
🔬 This is a nightly-only experimental API. (core_intrinsics)

intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library

Expand description

计算与指针的偏移量。

这被实现为内联函数,以避免与整数进行转换,因为转换会丢弃别名信息。

Safety

起始指针和结果指针都必须在已分配对象末尾的范围之内或一个字节内。 如果指针越界或发生算术溢出,则进一步使用返回值将导致不确定的行为。

此内联函数的稳定版本为 pointer::offset