wiki/content/20201120101047-as_mut_ptr_range.md

775 B

date id title
2020-11-20 6291dde0-b0b4-4128-89c3-1fa77d39527e as~mutptrrange~

Description

Returns the two unsafe mutable pointers spanning the slice.

The returned range is half-open, which means that the end pointer points one past the last element of the slice. This way, an empty slice is represented by two equal pointers, and the difference between the two pointers represents the size of the slice.

This function is useful for interacting with foreign interfaces which use two pointers to refer to a range of elements in memory, as is common in C++.

Declaration

pub fn as_mut_ptr_range(&mut self) -> Range<*mut T>

Traits for Range<A>

impl<A> Iterator for Range<A> where
    A: Step,     type Item = A;

Footnotes