Skip to content

Commit e071bdb

Browse files
committed
API: Remove deprecated ArrayView::into_slice (use to_slice)
This could really use either name - `into_slice` for the "into" semantic of preserving the lifetime parameter, or the `to_slice` name which is customary for `&self` methods. Both names have the problem that they compete with `ArrayBase::as_slice()`, but the doc has been improved to explain some of that.
1 parent dd5f840 commit e071bdb

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/impl_views/conversions.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,9 @@ where
3131

3232
/// Return the array’s data as a slice, if it is contiguous and in standard order.
3333
/// 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.
4637
pub fn to_slice(&self) -> Option<&'a [A]> {
4738
if self.is_standard_layout() {
4839
unsafe { Some(slice::from_raw_parts(self.ptr.as_ptr(), self.len())) }
@@ -120,6 +111,9 @@ where
120111
{
121112
/// Return the array’s data as a slice, if it is contiguous and in standard order.
122113
/// 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.
123117
pub fn into_slice(self) -> Option<&'a mut [A]> {
124118
self.into_slice_().ok()
125119
}

0 commit comments

Comments
 (0)