Skip to content

Commit 381c442

Browse files
committed
Fix slice::as_ptr_range doctest.
1 parent de9b660 commit 381c442

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/libcore/slice/mod.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,18 @@ impl<T> [T] {
422422
/// use two pointers to refer to a range of elements in memory, as is
423423
/// common in C++.
424424
///
425-
/// It can also be useful to check if a reference or pointer to an element
426-
/// refers to an element of this slice:
425+
/// It can also be useful to check if a pointer to an element refers to an
426+
/// element of this slice:
427427
///
428428
/// ```
429-
/// let a = [1,2,3];
430-
/// let x = &a[1];
431-
/// let y = &5;
432-
/// assert!(a.as_ptr_range().contains(x));
433-
/// assert!(!a.as_ptr_range().contains(y));
429+
/// #![feature(slice_ptr_range)]
430+
///
431+
/// let a = [1, 2, 3];
432+
/// let x = &a[1] as *const _;
433+
/// let y = &5 as *const _;
434+
///
435+
/// assert!(a.as_ptr_range().contains(&x));
436+
/// assert!(!a.as_ptr_range().contains(&y));
434437
/// ```
435438
///
436439
/// [`as_ptr`]: #method.as_ptr

0 commit comments

Comments
 (0)