Skip to content

Commit

Permalink
Revert "Make implentation methods for SliceIndex #[doc(hidden)]"
Browse files Browse the repository at this point in the history
This reverts commit 068fc44.
  • Loading branch information
tmccombs committed May 30, 2018
1 parent 068fc44 commit 7181337
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,37 +2009,31 @@ pub trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
/// Returns a shared reference to the output at this location, if in
/// bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
fn get(self, slice: &T) -> Option<&Self::Output>;

/// Returns a mutable reference to the output at this location, if in
/// bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
fn get_mut(self, slice: &mut T) -> Option<&mut Self::Output>;

/// Returns a shared reference to the output at this location, without
/// performing any bounds checking.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &T) -> &Self::Output;

/// Returns a mutable reference to the output at this location, without
/// performing any bounds checking.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut T) -> &mut Self::Output;

/// Returns a shared reference to the output at this location, panicking
/// if out of bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
fn index(self, slice: &T) -> &Self::Output;

/// Returns a mutable reference to the output at this location, panicking
/// if out of bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
#[doc(hidden)]
fn index_mut(self, slice: &mut T) -> &mut Self::Output;
}

Expand All @@ -2048,7 +2042,6 @@ impl<T> SliceIndex<[T]> for usize {
type Output = T;

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&T> {
if self < slice.len() {
unsafe {
Expand All @@ -2060,7 +2053,6 @@ impl<T> SliceIndex<[T]> for usize {
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut T> {
if self < slice.len() {
unsafe {
Expand All @@ -2072,26 +2064,22 @@ impl<T> SliceIndex<[T]> for usize {
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &T {
&*slice.as_ptr().offset(self as isize)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut T {
&mut *slice.as_mut_ptr().offset(self as isize)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &T {
// NB: use intrinsic indexing
&(*slice)[self]
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut T {
// NB: use intrinsic indexing
&mut (*slice)[self]
Expand All @@ -2103,7 +2091,6 @@ impl<T> SliceIndex<[T]> for ops::Range<usize> {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
if self.start > self.end || self.end > slice.len() {
None
Expand All @@ -2115,7 +2102,6 @@ impl<T> SliceIndex<[T]> for ops::Range<usize> {
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
if self.start > self.end || self.end > slice.len() {
None
Expand All @@ -2127,19 +2113,16 @@ impl<T> SliceIndex<[T]> for ops::Range<usize> {
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
from_raw_parts(slice.as_ptr().offset(self.start as isize), self.end - self.start)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
from_raw_parts_mut(slice.as_mut_ptr().offset(self.start as isize), self.end - self.start)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
if self.start > self.end {
slice_index_order_fail(self.start, self.end);
Expand All @@ -2152,7 +2135,6 @@ impl<T> SliceIndex<[T]> for ops::Range<usize> {
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
if self.start > self.end {
slice_index_order_fail(self.start, self.end);
Expand All @@ -2170,37 +2152,31 @@ impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
(0..self.end).get(slice)
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
(0..self.end).get_mut(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
(0..self.end).get_unchecked(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
(0..self.end).get_unchecked_mut(slice)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
(0..self.end).index(slice)
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
(0..self.end).index_mut(slice)
}
Expand All @@ -2211,37 +2187,31 @@ impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
(self.start..slice.len()).get(slice)
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
(self.start..slice.len()).get_mut(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
(self.start..slice.len()).get_unchecked(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
(self.start..slice.len()).get_unchecked_mut(slice)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
(self.start..slice.len()).index(slice)
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
(self.start..slice.len()).index_mut(slice)
}
Expand All @@ -2252,37 +2222,31 @@ impl<T> SliceIndex<[T]> for ops::RangeFull {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
Some(slice)
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
Some(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
slice
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
slice
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
slice
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
slice
}
Expand All @@ -2294,40 +2258,34 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
if self.end == usize::max_value() { None }
else { (self.start..self.end + 1).get(slice) }
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
if self.end == usize::max_value() { None }
else { (self.start..self.end + 1).get_mut(slice) }
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
(self.start..self.end + 1).get_unchecked(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
(self.start..self.end + 1).get_unchecked_mut(slice)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
if self.end == usize::max_value() { slice_index_overflow_fail(); }
(self.start..self.end + 1).index(slice)
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
if self.end == usize::max_value() { slice_index_overflow_fail(); }
(self.start..self.end + 1).index_mut(slice)
Expand All @@ -2339,37 +2297,31 @@ impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
type Output = [T];

#[inline]
#[doc(hidden)]
fn get(self, slice: &[T]) -> Option<&[T]> {
(0..=self.end).get(slice)
}

#[inline]
#[doc(hidden)]
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
(0..=self.end).get_mut(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked(self, slice: &[T]) -> &[T] {
(0..=self.end).get_unchecked(slice)
}

#[inline]
#[doc(hidden)]
unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] {
(0..=self.end).get_unchecked_mut(slice)
}

#[inline]
#[doc(hidden)]
fn index(self, slice: &[T]) -> &[T] {
(0..=self.end).index(slice)
}

#[inline]
#[doc(hidden)]
fn index_mut(self, slice: &mut [T]) -> &mut [T] {
(0..=self.end).index_mut(slice)
}
Expand Down

0 comments on commit 7181337

Please sign in to comment.