Skip to content

Commit

Permalink
fixed #51 and fixed #54
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Dec 27, 2023
1 parent aa8c74d commit bdd2aef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/discrete_finite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ macro_rules! foo {
};
}

foo!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128,);
foo!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize,);
18 changes: 10 additions & 8 deletions src/discrete_range_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ where
pub fn remove_overlapping<'a, Q>(
&'a mut self,
range: Q,
) -> impl Iterator<Item = (K, V)> + '_
) -> impl Iterator<Item = (K, V)>
where
Q: RangeType<I> + 'a,
{
Expand Down Expand Up @@ -453,10 +453,7 @@ where
/// );
/// assert_eq!(base, after_cut);
/// ```
pub fn cut<'a, Q>(
&'a mut self,
range: Q,
) -> impl Iterator<Item = (K, V)> + '_
pub fn cut<'a, Q>(&'a mut self, range: Q) -> impl Iterator<Item = (K, V)>
where
Q: RangeType<I> + 'a,
V: Clone,
Expand Down Expand Up @@ -522,7 +519,7 @@ where
range: Q,
left_overlapping: Option<K>,
right_overlapping: Option<K>,
) -> impl Iterator<Item = (K, V)> + '_
) -> impl Iterator<Item = (K, V)>
where
Q: RangeType<I> + 'a,
V: Clone,
Expand Down Expand Up @@ -1194,14 +1191,19 @@ where
/// [(ie(2, 4), false), (ie(4, 6), true), (ie(6, 8), false)]
/// );
/// ```
pub fn insert_overwrite(&mut self, range: K, value: V)
pub fn insert_overwrite(
&mut self,
range: K,
value: V,
) -> impl Iterator<Item = (K, V)>
where
V: Clone,
{
invalid_range_panic(range);

let _ = self.cut(range);
let cut = self.cut(range);
self.insert_unchecked(range, value);
cut
}

/// Allocates a `DiscreteRangeMap` and moves the given entries from
Expand Down
8 changes: 4 additions & 4 deletions src/discrete_range_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ where
pub fn remove_overlapping<'a, Q>(
&'a mut self,
range: Q,
) -> impl Iterator<Item = K> + '_
) -> impl Iterator<Item = K>
where
Q: RangeType<I> + 'a,
{
self.inner.remove_overlapping(range).map(first)
}
/// See [`DiscreteRangeMap::cut()`] for more details.
pub fn cut<'a, Q>(&'a mut self, range: Q) -> impl Iterator<Item = K> + '_
pub fn cut<'a, Q>(&'a mut self, range: Q) -> impl Iterator<Item = K>
where
Q: RangeType<I> + 'a,
{
Expand Down Expand Up @@ -131,8 +131,8 @@ where
self.inner.insert_merge_touching_or_overlapping(range, ())
}
/// See [`DiscreteRangeMap::insert_overwrite()`] for more details.
pub fn insert_overwrite(&mut self, range: K) {
self.inner.insert_overwrite(range, ())
pub fn insert_overwrite(&mut self, range: K) -> impl Iterator<Item = K> {
self.inner.insert_overwrite(range, ()).map(first)
}
/// See [`DiscreteRangeMap::from_slice_strict()`] for more details.
pub fn from_slice_strict<const N: usize>(
Expand Down

0 comments on commit bdd2aef

Please sign in to comment.