|
31 | 31 |
|
32 | 32 | /// Return the array’s data as a slice, if it is contiguous and in standard order. |
33 | 33 | /// Return `None` otherwise. |
34 | | - #[deprecated(note = "`into_slice` has been renamed to `to_slice`", since = "0.13.0")] |
35 | | - #[allow(clippy::wrong_self_convention)] |
36 | | - pub fn into_slice(&self) -> Option<&'a [A]> { |
37 | | - if self.is_standard_layout() { |
38 | | - unsafe { Some(slice::from_raw_parts(self.ptr.as_ptr(), self.len())) } |
39 | | - } else { |
40 | | - None |
41 | | - } |
42 | | - } |
43 | | - |
44 | | - /// Return the array’s data as a slice, if it is contiguous and in standard order. |
45 | | - /// Return `None` otherwise. |
| 34 | + /// |
| 35 | + /// Note that while the method is similar to [`ArrayBase::as_slice()`], this method tranfers |
| 36 | + /// the view's lifetime to the slice, so it is a bit more powerful. |
46 | 37 | pub fn to_slice(&self) -> Option<&'a [A]> { |
47 | 38 | if self.is_standard_layout() { |
48 | 39 | unsafe { Some(slice::from_raw_parts(self.ptr.as_ptr(), self.len())) } |
@@ -120,6 +111,9 @@ where |
120 | 111 | { |
121 | 112 | /// Return the array’s data as a slice, if it is contiguous and in standard order. |
122 | 113 | /// Return `None` otherwise. |
| 114 | + /// |
| 115 | + /// Note that while this is similar to [`ArrayBase::as_slice_mut()`], this method tranfers the |
| 116 | + /// view's lifetime to the slice. |
123 | 117 | pub fn into_slice(self) -> Option<&'a mut [A]> { |
124 | 118 | self.into_slice_().ok() |
125 | 119 | } |
|
0 commit comments