Skip to content

Commit b2abf1c

Browse files
committed
FEAT: Try to do new names for elem. elem → index and the others follow.
The logic is that: - get() is for checked subscripting that returns Option<&T> - Index::index is for checked subscripting that returns &T We can reuse the index name for checked subscripting that returns &T. Naming it the same as the trait method is no problem (the inherent method has precedence).
1 parent bd6d077 commit b2abf1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/impl_views.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'a, A, D> ArrayView<'a, A, D>
139139
/// This method is like `Index::index` but with a longer lifetime (matching
140140
/// the array view); which we can't do for general arrays and not in the
141141
/// `Index` trait.
142-
pub fn elem<I>(&self, index: I) -> &'a A
142+
pub fn index<I>(&self, index: I) -> &'a A
143143
where I: NdIndex<D>,
144144
{
145145
debug_bounds_check!(self, index);
@@ -154,7 +154,7 @@ impl<'a, A, D> ArrayView<'a, A, D>
154154
///
155155
/// This method is like `elem` with a longer lifetime (matching the array
156156
/// view); which we can't do for general arrays.
157-
pub unsafe fn uelem<I>(&self, index: I) -> &'a A
157+
pub unsafe fn uindex<I>(&self, index: I) -> &'a A
158158
where I: NdIndex<D>,
159159
{
160160
debug_bounds_check!(self, index);
@@ -266,7 +266,7 @@ impl<'a, A, D> ArrayViewMut<'a, A, D>
266266
/// This method is like `Index::index` but with a longer lifetime (matching
267267
/// the array view); which we can't do for general arrays and not in the
268268
/// `Index` trait.
269-
pub fn into_elem<I>(mut self, index: I) -> &'a mut A
269+
pub fn into_index_mut<I>(mut self, index: I) -> &'a mut A
270270
where I: NdIndex<D>,
271271
{
272272
debug_bounds_check!(self, index);
@@ -282,7 +282,7 @@ impl<'a, A, D> ArrayViewMut<'a, A, D>
282282
/// Convert a mutable array view to a mutable reference of a element without boundary check
283283
///
284284
///
285-
pub unsafe fn into_elem_unchecked<I>(mut self, index: I) -> &'a mut A
285+
pub unsafe fn into_index_mut_unchecked<I>(mut self, index: I) -> &'a mut A
286286
where I: NdIndex<D>
287287
{
288288
debug_bounds_check!(self, index);

0 commit comments

Comments
 (0)