From 4329d847c60a7729ed23d5321c62967c88aab223 Mon Sep 17 00:00:00 2001 From: ripytide Date: Wed, 5 Apr 2023 14:39:10 +0100 Subject: [PATCH] removed split_off from set.rs too --- src/range_bounds_set.rs | 46 ----------------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/range_bounds_set.rs b/src/range_bounds_set.rs index 40d8cb1..04ee8fb 100644 --- a/src/range_bounds_set.rs +++ b/src/range_bounds_set.rs @@ -728,52 +728,6 @@ where pub fn last(&self) -> Option<&K> { self.map.last_entry().map(|(key, _)| key) } - - /// Splits the set in two at the given `start_bound()`. Returns - /// the full or partial `RangeBounds` after the split. - /// - /// If the remaining `RangeBounds` left in either the base or the - /// returned set are not able be created with the - /// [`TryFromBounds`] trait then a [`TryFromBoundsError`] will be - /// returned and the base set will not be split. - /// - /// # Examples - /// ``` - /// use std::ops::Bound; - /// - /// use range_bounds_map::{RangeBoundsSet, TryFromBoundsError}; - /// - /// let mut a = - /// RangeBoundsSet::from_slice_strict([1..2, 4..8, 10..16]) - /// .unwrap(); - /// - /// // Fails because that would leave an Inclusive-Inclusive - /// // `RangeBounds` in `a` - /// assert_eq!( - /// a.split_off(Bound::Excluded(6)), - /// Err(TryFromBoundsError) - /// ); - /// - /// let b = a.split_off(Bound::Included(6)).unwrap(); - /// - /// assert_eq!(a.into_iter().collect::>(), [1..2, 4..6],); - /// assert_eq!(b.into_iter().collect::>(), [6..8, 10..16],); - /// ``` - #[trivial] - pub fn split_off( - &mut self, - start_bound: Bound, - ) -> Result, TryFromBoundsError> - where - K: TryFromBounds + Clone, - { - let mut set = RangeBoundsSet::new(); - for (range_bounds, _) in self.map.split_off(start_bound)? { - set.insert_strict(range_bounds).unwrap(); - } - - Ok(set) - } } impl IntoIterator for RangeBoundsSet