Skip to content

Commit 4e2e60c

Browse files
committed
FIX: Internal cleanup, rename into_slice_ -> try_into_slice
1 parent e071bdb commit 4e2e60c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/impl_views/conversions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ where
115115
/// Note that while this is similar to [`ArrayBase::as_slice_mut()`], this method tranfers the
116116
/// view's lifetime to the slice.
117117
pub fn into_slice(self) -> Option<&'a mut [A]> {
118-
self.into_slice_().ok()
118+
self.try_into_slice().ok()
119119
}
120120
}
121121

@@ -173,7 +173,9 @@ where
173173
ElementsBaseMut::new(self)
174174
}
175175

176-
pub(crate) fn into_slice_(self) -> Result<&'a mut [A], Self> {
176+
/// Return the array’s data as a slice, if it is contiguous and in standard order.
177+
/// Otherwise return self in the Err branch of the result.
178+
pub(crate) fn try_into_slice(self) -> Result<&'a mut [A], Self> {
177179
if self.is_standard_layout() {
178180
unsafe { Ok(slice::from_raw_parts_mut(self.ptr.as_ptr(), self.len())) }
179181
} else {

src/iterators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ where
294294
{
295295
pub(crate) fn new(self_: ArrayViewMut<'a, A, D>) -> Self {
296296
IterMut {
297-
inner: match self_.into_slice_() {
297+
inner: match self_.try_into_slice() {
298298
Ok(x) => ElementsRepr::Slice(x.iter_mut()),
299299
Err(self_) => ElementsRepr::Counted(self_.into_elements_base()),
300300
},

0 commit comments

Comments
 (0)