diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2019-10-25 17:22:03 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2019-10-25 18:01:31 +0200 |
| commit | 381c4425b7d0f428df6576f085ea03b1d42e06af (patch) | |
| tree | 0c576a8f516cc311204f97f521656215c4b35874 /src/libcore | |
| parent | de9b660a40728d4c4213f2ec7a1c99a9bc352023 (diff) | |
| download | rust-381c4425b7d0f428df6576f085ea03b1d42e06af.tar.gz rust-381c4425b7d0f428df6576f085ea03b1d42e06af.zip | |
Fix slice::as_ptr_range doctest.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/slice/mod.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 185913a47f1..cdada1252d2 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -422,15 +422,18 @@ impl<T> [T] { /// use two pointers to refer to a range of elements in memory, as is /// common in C++. /// - /// It can also be useful to check if a reference or pointer to an element - /// refers to an element of this slice: + /// It can also be useful to check if a pointer to an element refers to an + /// element of this slice: /// /// ``` - /// let a = [1,2,3]; - /// let x = &a[1]; - /// let y = &5; - /// assert!(a.as_ptr_range().contains(x)); - /// assert!(!a.as_ptr_range().contains(y)); + /// #![feature(slice_ptr_range)] + /// + /// let a = [1, 2, 3]; + /// let x = &a[1] as *const _; + /// let y = &5 as *const _; + /// + /// assert!(a.as_ptr_range().contains(&x)); + /// assert!(!a.as_ptr_range().contains(&y)); /// ``` /// /// [`as_ptr`]: #method.as_ptr |
