about summary refs log tree commit diff
path: root/library/core/src/ops
diff options
context:
space:
mode:
authordylni <46035563+dylni@users.noreply.github.com>2021-02-01 21:20:44 -0500
committerdylni <46035563+dylni@users.noreply.github.com>2021-02-12 22:01:04 -0500
commit5d519eaa6e9a583257b2f9e28a743ab85d1cabc5 (patch)
treef7c58cd480bae318802adfb646a5838effa53df3 /library/core/src/ops
parentf6111a256e94855f18f36f02930f8b0ae0012542 (diff)
Rename `Range::ensure_subset_of` to `slice::range`
Diffstat (limited to 'library/core/src/ops')
-rw-r--r--library/core/src/ops/range.rs101
1 files changed, 0 insertions, 101 deletions
diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs
index b30ff9450ff..dbeb3912130 100644
--- a/library/core/src/ops/range.rs
+++ b/library/core/src/ops/range.rs
@@ -1,9 +1,5 @@
 use crate::fmt;
 use crate::hash::Hash;
-use crate::slice::index::{
-    slice_end_index_len_fail, slice_end_index_overflow_fail, slice_index_order_fail,
-    slice_start_index_overflow_fail,
-};
 
 /// An unbounded range (`..`).
 ///
@@ -151,103 +147,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
     }
 }
 
-impl Range<usize> {
-    /// Performs bounds-checking of a range.
-    ///
-    /// This method is similar to [`Index::index`] for slices, but it returns a
-    /// `Range` equivalent to `range`. You can use this method to turn any range
-    /// into `start` and `end` values.
-    ///
-    /// `bounds` is the range of the slice to use for bounds-checking. It should
-    /// be a [`RangeTo`] range that ends at the length of the slice.
-    ///
-    /// The returned `Range` is safe to pass to [`slice::get_unchecked`] and
-    /// [`slice::get_unchecked_mut`] for slices with the given range.
-    ///
-    /// [`slice::get_unchecked`]: ../../std/primitive.slice.html#method.get_unchecked
-    /// [`slice::get_unchecked_mut`]: ../../std/primitive.slice.html#method.get_unchecked_mut
-    ///
-    /// # Panics
-    ///
-    /// Panics if `range` would be out of bounds.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// #![feature(range_ensure_subset_of)]
-    ///
-    /// use std::ops::Range;
-    ///
-    /// let v = [10, 40, 30];
-    /// assert_eq!(1..2, Range::ensure_subset_of(1..2, ..v.len()));
-    /// assert_eq!(0..2, Range::ensure_subset_of(..2, ..v.len()));
-    /// assert_eq!(1..3, Range::ensure_subset_of(1.., ..v.len()));
-    /// ```
-    ///
-    /// Panics when [`Index::index`] would panic:
-    ///
-    /// ```should_panic
-    /// #![feature(range_ensure_subset_of)]
-    ///
-    /// use std::ops::Range;
-    ///
-    /// Range::ensure_subset_of(2..1, ..3);
-    /// ```
-    ///
-    /// ```should_panic
-    /// #![feature(range_ensure_subset_of)]
-    ///
-    /// use std::ops::Range;
-    ///
-    /// Range::ensure_subset_of(1..4, ..3);
-    /// ```
-    ///
-    /// ```should_panic
-    /// #![feature(range_ensure_subset_of)]
-    ///
-    /// use std::ops::Range;
-    ///
-    /// Range::ensure_subset_of(1..=usize::MAX, ..3);
-    /// ```
-    ///
-    /// [`Index::index`]: crate::ops::Index::index
-    #[track_caller]
-    #[unstable(feature = "range_ensure_subset_of", issue = "76393")]
-    pub fn ensure_subset_of<R>(range: R, bounds: RangeTo<usize>) -> Self
-    where
-        R: RangeBounds<usize>,
-    {
-        let len = bounds.end;
-
-        let start: Bound<&usize> = range.start_bound();
-        let start = match start {
-            Bound::Included(&start) => start,
-            Bound::Excluded(start) => {
-                start.checked_add(1).unwrap_or_else(|| slice_start_index_overflow_fail())
-            }
-            Bound::Unbounded => 0,
-        };
-
-        let end: Bound<&usize> = range.end_bound();
-        let end = match end {
-            Bound::Included(end) => {
-                end.checked_add(1).unwrap_or_else(|| slice_end_index_overflow_fail())
-            }
-            Bound::Excluded(&end) => end,
-            Bound::Unbounded => len,
-        };
-
-        if start > end {
-            slice_index_order_fail(start, end);
-        }
-        if end > len {
-            slice_end_index_len_fail(end, len);
-        }
-
-        Self { start, end }
-    }
-}
-
 /// A range only bounded inclusively below (`start..`).
 ///
 /// The `RangeFrom` `start..` contains all values with `x >= start`.