rollup merge of #24610: nagisa/offset-docs
This commit is contained in:
commit
b164f66172
@ -255,12 +255,17 @@ extern "rust-intrinsic" {
|
|||||||
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
||||||
pub fn owns_managed<T>() -> bool;
|
pub fn owns_managed<T>() -> bool;
|
||||||
|
|
||||||
/// Calculates the offset from a pointer. The offset *must* be in-bounds of
|
/// Calculates the offset from a pointer.
|
||||||
/// the object, or one-byte-past-the-end. An arithmetic overflow is also
|
|
||||||
/// undefined behaviour.
|
|
||||||
///
|
///
|
||||||
/// This is implemented as an intrinsic to avoid converting to and from an
|
/// This is implemented as an intrinsic to avoid converting to and from an
|
||||||
/// integer, since the conversion would throw away aliasing information.
|
/// integer, since the conversion would throw away aliasing information.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// Both the starting and resulting pointer must be either in bounds or one
|
||||||
|
/// byte past the end of an allocated object. If either pointer is out of
|
||||||
|
/// bounds or arithmetic overflow occurs then any further use of the
|
||||||
|
/// returned value will result in undefined behavior.
|
||||||
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
|
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
|
||||||
|
|
||||||
/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source
|
/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source
|
||||||
|
@ -284,9 +284,10 @@ impl<T: ?Sized> *const T {
|
|||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The offset must be in-bounds of the object, or one-byte-past-the-end.
|
/// Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
|
/// byte past the end of an allocated object. If either pointer is out of
|
||||||
/// the pointer is used.
|
/// bounds or arithmetic overflow occurs then
|
||||||
|
/// any further use of the returned value will result in undefined behavior.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn offset(self, count: isize) -> *const T where T: Sized {
|
pub unsafe fn offset(self, count: isize) -> *const T where T: Sized {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user