Skip to content

Commit fa65c45

Browse files
committed
Make the ArrayParts struct private.
It's easier inside the library to have ArrayParts be public and have LayoutRef be a type alias. Outside of the library, though, having the ArrayParts be a public interface exposes implementation details. If we ever wanted to switch to a trait object or another approach for DSTs, having ArrayParts be public would make that harder.
1 parent e5277c0 commit fa65c45

File tree

12 files changed

+190
-134
lines changed

12 files changed

+190
-134
lines changed

src/arraytraits.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
T: AsLayoutRef<A, D> + ?Sized,
4646
{
4747
let layout_ref = _a.as_ref();
48-
debug_bounds_check!(layout_ref, *_index);
48+
debug_bounds_check_ref!(layout_ref, *_index);
4949
}
5050

5151
/// Access the element at **index**.
@@ -61,11 +61,11 @@ where
6161
#[inline]
6262
fn index(&self, index: I) -> &Self::Output
6363
{
64-
debug_bounds_check!(self, index);
64+
debug_bounds_check_ref!(self, index);
6565
unsafe {
66-
&*self.ptr.as_ptr().offset(
66+
&*self._ptr().as_ptr().offset(
6767
index
68-
.index_checked(&self.dim, &self.strides)
68+
.index_checked(&self._dim(), &self._strides())
6969
.unwrap_or_else(|| array_out_of_bounds()),
7070
)
7171
}
@@ -83,11 +83,11 @@ where
8383
#[inline]
8484
fn index_mut(&mut self, index: I) -> &mut A
8585
{
86-
debug_bounds_check!(self, index);
86+
debug_bounds_check_ref!(self, index);
8787
unsafe {
8888
&mut *self.as_mut_ptr().offset(
8989
index
90-
.index_checked(&self.dim, &self.strides)
90+
.index_checked(&self._dim(), &self._strides())
9191
.unwrap_or_else(|| array_out_of_bounds()),
9292
)
9393
}

src/impl_clone.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// except according to those terms.
88

99
use crate::imp_prelude::*;
10-
use crate::ArrayParts;
1110
use crate::ArrayPartsSized;
1211
use crate::RawDataClone;
1312

src/impl_dyn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl<A> LayoutRef<A, IxDyn>
3131
pub fn insert_axis_inplace(&mut self, axis: Axis)
3232
{
3333
assert!(axis.index() <= self.ndim());
34-
self.dim = self.dim.insert_axis(axis);
35-
self.strides = self.strides.insert_axis(axis);
34+
self.0.dim = self._dim().insert_axis(axis);
35+
self.0.strides = self._strides().insert_axis(axis);
3636
}
3737

3838
/// Collapses the array to `index` along the axis and removes the axis,
@@ -54,8 +54,8 @@ impl<A> LayoutRef<A, IxDyn>
5454
pub fn index_axis_inplace(&mut self, axis: Axis, index: usize)
5555
{
5656
self.collapse_axis(axis, index);
57-
self.dim = self.dim.remove_axis(axis);
58-
self.strides = self.strides.remove_axis(axis);
57+
self.0.dim = self._dim().remove_axis(axis);
58+
self.0.strides = self._strides().remove_axis(axis);
5959
}
6060
}
6161

0 commit comments

Comments
 (0)