1
Fork 0

Fix slice::as_ptr_range doctest.

This commit is contained in:
Mara Bos 2019-10-25 17:22:03 +02:00
parent de9b660a40
commit 381c4425b7

View file

@ -422,15 +422,18 @@ impl<T> [T] {
/// use two pointers to refer to a range of elements in memory, as is /// use two pointers to refer to a range of elements in memory, as is
/// common in C++. /// common in C++.
/// ///
/// It can also be useful to check if a reference or pointer to an element /// It can also be useful to check if a pointer to an element refers to an
/// refers to an element of this slice: /// element of this slice:
/// ///
/// ``` /// ```
/// let a = [1,2,3]; /// #![feature(slice_ptr_range)]
/// let x = &a[1]; ///
/// let y = &5; /// let a = [1, 2, 3];
/// assert!(a.as_ptr_range().contains(x)); /// let x = &a[1] as *const _;
/// assert!(!a.as_ptr_range().contains(y)); /// let y = &5 as *const _;
///
/// assert!(a.as_ptr_range().contains(&x));
/// assert!(!a.as_ptr_range().contains(&y));
/// ``` /// ```
/// ///
/// [`as_ptr`]: #method.as_ptr /// [`as_ptr`]: #method.as_ptr