diff --git a/src/lib.rs b/src/lib.rs
index 707760a..cd19c46 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,12 +25,12 @@ along with range_bounds_map. If not, see .
#![allow(clippy::needless_return)]
pub(crate) mod bound_ord;
pub mod range_bounds_map;
-pub mod range_bounds_set;
+//pub mod range_bounds_set;
pub mod try_from_bounds;
pub use crate::range_bounds_map::{
OverlapError, OverlapOrTryFromBoundsError, RangeBoundsMap,
TryFromBoundsError,
};
-pub use crate::range_bounds_set::RangeBoundsSet;
+//pub use crate::range_bounds_set::RangeBoundsSet;
pub use crate::try_from_bounds::TryFromBounds;
diff --git a/src/range_bounds_map.rs b/src/range_bounds_map.rs
index 0a46830..6f31266 100644
--- a/src/range_bounds_map.rs
+++ b/src/range_bounds_map.rs
@@ -153,7 +153,8 @@ pub struct OverlapError;
/// Bound::Exclusive(8))`. However, since the `RangeBounds` type of
/// this `RangeBoundsMap` is `Range<{integer}>` the latter of the two
/// new `RangeBounds` is "unrepresentable", and hence will fail to be
-/// created via [`TryFromBounds`].
+/// created via [`TryFromBounds`] and [`RangeBoundsMap::cut()`] will
+/// return Err(TryFromBoundsError).
///
/// ```
/// use range_bounds_map::{RangeBoundsMap, TryFromBoundsError};
@@ -161,10 +162,7 @@ pub struct OverlapError;
/// let mut range_bounds_map =
/// RangeBoundsMap::try_from([(2..8, true)]).unwrap();
///
-/// assert_eq!(
-/// range_bounds_map.cut(&(4..=6)),
-/// Err(TryFromBoundsError)
-/// );
+/// assert!(range_bounds_map.cut(&(4..=6)).is_err());
/// ```
///
/// # Example with `insert_coalesce_*` functions.
@@ -663,6 +661,8 @@ where
///
/// # Examples
/// ```
+ /// use std::ops::Bound;
+ ///
/// use range_bounds_map::{RangeBoundsMap, TryFromBoundsError};
///
/// let mut base = RangeBoundsMap::try_from([
@@ -677,7 +677,7 @@ where
/// .unwrap();
///
/// assert_eq!(
- /// base.cut(&(2..40)).collect::>(),
+ /// base.cut(&(2..40)).unwrap().collect::>(),
/// [
/// ((Bound::Included(2), Bound::Excluded(4)), false),
/// ((Bound::Included(4), Bound::Excluded(8)), true),
@@ -685,9 +685,9 @@ where
/// ]
/// );
/// assert_eq!(base, after_cut);
- /// assert_eq!(base.cut(&(60..=80)), Err(TryFromBoundsError));
+ /// assert!(base.cut(&(60..=80)).is_err());
/// ```
- #[tested]
+ #[untested]
pub fn cut(
&mut self,
range_bounds: &Q,
@@ -778,10 +778,8 @@ where
}
/// Identical to [`RangeBoundsMap::cut()`] except it returns an
- /// iterator of `Result, Value),
- /// TryFromBoundsError>` after applying TryFromBounds to the
- /// `(Bound, Bound)`s in in the iterator returned by
- /// [`RangeBoundsMap::cut()`].
+ /// iterator of `(Result,
+ /// Value)`.
///
/// # Examples
/// ```
@@ -799,13 +797,13 @@ where
/// .unwrap();
///
/// assert_eq!(
- /// base.cut_same(&(2..40)).collect::>(),
+ /// base.cut_same(&(2..40)).unwrap().collect::>(),
/// [(Ok(2..4), false), (Ok(4..8), true), (Ok(8..40), false)]
/// );
/// assert_eq!(base, after_cut);
- /// assert_eq!(base.cut_same(&(60..=80)), Err(TryFromBoundsError));
+ /// assert!(base.cut_same(&(60..=80)).is_err());
/// ```
- #[tested]
+ #[trivial]
pub fn cut_same(
&mut self,
range_bounds: &Q,
@@ -858,7 +856,7 @@ where
/// ]
/// );
/// ```
- #[tested]
+ #[untested]
pub fn gaps<'a, Q>(
&'a self,
outer_range_bounds: &'a Q,
@@ -925,6 +923,44 @@ where
.filter(is_valid_range_bounds::<(Bound<&I>, Bound<&I>), I>);
}
+ /// Identical to [`RangeBoundsMap::gaps()`] except it returns an
+ /// iterator of `Result`.
+ ///
+ /// # Examples
+ /// ```
+ /// use std::ops::Bound;
+ ///
+ /// use range_bounds_map::{RangeBoundsMap, TryFromBoundsError};
+ ///
+ /// let range_bounds_map = RangeBoundsMap::try_from([
+ /// (1..3, false),
+ /// (5..7, true),
+ /// (9..100, false),
+ /// ])
+ /// .unwrap();
+ ///
+ /// let mut gaps_same = range_bounds_map.gaps_same(&(2..));
+ ///
+ /// assert_eq!(
+ /// gaps_same.collect::>(),
+ /// [Ok(3..5), Ok(7..9), Err(TryFromBoundsError),]
+ /// );
+ /// ```
+ #[trivial]
+ pub fn gaps_same<'a, Q>(
+ &'a self,
+ outer_range_bounds: &'a Q,
+ ) -> impl Iterator- > + '_
+ where
+ Q: RangeBounds,
+ K: TryFromBounds,
+ {
+ self.gaps(outer_range_bounds).map(|(start, end)| {
+ K::try_from_bounds(start.cloned(), end.cloned())
+ .ok_or(TryFromBoundsError)
+ })
+ }
+
/// Returns `true` if the map covers every point in the given
/// `RangeBounds`, and `false` if it doesn't.
///
@@ -1523,7 +1559,7 @@ where
result.inside_cut = Some((cut_start, base_end));
result.after_cut = Some((base_start, flip_bound(cut_start)));
}
- Config::LeftContainsRight(a, b) => {
+ Config::LeftContainsRight(_, _) => {
result.before_cut = Some((base_start, flip_bound(cut_start)));
result.inside_cut = Some(cut_all);
result.after_cut = Some((flip_bound(cut_end), base_end));