Skip to content

Commit

Permalink
Respell Segment types trait implementations.
Browse files Browse the repository at this point in the history
This change respells `Segment` types in `Segmentation` and `SegmentedBy`
implementations using type definitions for the corresponding collection.
This makes documentation a bit clearer.
  • Loading branch information
olson-sean-k committed Jul 26, 2024
1 parent 22bf3c7 commit 5cdd138
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/array_vec1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ impl<T, const N: usize> Ranged for ArrayVec<T, N> {
}

impl<T, const N: usize> Segmentation for ArrayVec<T, N> {
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> ArrayVecSegment<'_, T, N> {
self.segment(Ranged::tail(self))
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> ArrayVecSegment<'_, T, N> {
self.segment(Ranged::rtail(self))
}
}
Expand All @@ -52,7 +52,7 @@ impl<T, R, const N: usize> segment::SegmentedBy<R> for ArrayVec<T, N>
where
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> ArrayVecSegment<'_, T, N> {
Segment::intersect(self, &range::ordered_range_offsets(range))
}
}
Expand Down Expand Up @@ -442,11 +442,11 @@ impl<T, const N: usize> Segmentation for ArrayVec1<T, N>
where
[T; N]: Array1,
{
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> ArrayVec1Segment<'_, T, N> {
self.segment(Ranged::tail(&self.items))
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> ArrayVec1Segment<'_, T, N> {
self.segment(Ranged::rtail(&self.items))
}
}
Expand All @@ -464,7 +464,7 @@ where
[T; N]: Array1,
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> ArrayVec1Segment<'_, T, N> {
Segment::intersect_strict_subset(&mut self.items, &range::ordered_range_offsets(range))
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/btree_map1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ impl<K, V> Segmentation for BTreeMap<K, V>
where
K: Copy + Ord,
{
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> BTreeMapSegment<'_, K, V> {
match Ranged::tail(self).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(self),
}
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> BTreeMapSegment<'_, K, V> {
match Ranged::rtail(self).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(self),
Expand All @@ -86,7 +86,7 @@ where
K: Copy + Ord,
R: RangeBounds<K>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> BTreeMapSegment<'_, K, V> {
Segment::intersect(self, &range::ordered_range_bounds(range))
}
}
Expand Down Expand Up @@ -700,14 +700,14 @@ impl<K, V> Segmentation for BTreeMap1<K, V>
where
K: Copy + Ord,
{
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> BTreeMap1Segment<'_, K, V> {
match Ranged::tail(&self.items).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(&mut self.items),
}
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> BTreeMap1Segment<'_, K, V> {
match Ranged::rtail(&self.items).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(&mut self.items),
Expand All @@ -729,7 +729,7 @@ where
K: Copy + Ord,
R: RangeBounds<K>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> BTreeMap1Segment<'_, K, V> {
Segment::intersect_strict_subset(&mut self.items, &range::ordered_range_bounds(range))
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/btree_set1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ impl<T> Segmentation for BTreeSet<T>
where
T: Copy + Ord,
{
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> BTreeSetSegment<'_, T> {
match Ranged::tail(self).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(self),
}
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> BTreeSetSegment<'_, T> {
match Ranged::rtail(self).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(self),
Expand All @@ -77,7 +77,7 @@ where
T: Copy + Ord,
R: RangeBounds<T>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> BTreeSetSegment<'_, T> {
Segment::intersect(self, &range::ordered_range_bounds(range))
}
}
Expand Down Expand Up @@ -449,14 +449,14 @@ impl<T> Segmentation for BTreeSet1<T>
where
T: Copy + Ord,
{
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> BTreeSet1Segment<'_, T> {
match Ranged::tail(&self.items).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(&mut self.items),
}
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> BTreeSet1Segment<'_, T> {
match Ranged::rtail(&self.items).try_into_range_inclusive() {
Some(range) => self.segment(range),
_ => Segment::empty(&mut self.items),
Expand All @@ -478,7 +478,7 @@ where
T: Copy + Ord,
R: RangeBounds<T>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> BTreeSet1Segment<'_, T> {
Segment::intersect_strict_subset(&mut self.items, &range::ordered_range_bounds(range))
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/vec1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ impl<T> Ranged for Vec<T> {
}

impl<T> Segmentation for Vec<T> {
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> VecSegment<'_, T> {
self.segment(Ranged::tail(self))
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> VecSegment<'_, T> {
self.segment(Ranged::rtail(self))
}
}
Expand All @@ -58,7 +58,7 @@ impl<T, R> segment::SegmentedBy<R> for Vec<T>
where
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> VecSegment<'_, T> {
Segment::intersect(self, &range::ordered_range_offsets(range))
}
}
Expand Down Expand Up @@ -440,11 +440,11 @@ impl<T> IntoIterator1 for Vec1<T> {
}

impl<T> Segmentation for Vec1<T> {
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> Vec1Segment<'_, T> {
self.segment(Ranged::tail(&self.items))
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> Vec1Segment<'_, T> {
self.segment(Ranged::rtail(&self.items))
}
}
Expand All @@ -458,7 +458,7 @@ impl<T, R> segment::SegmentedBy<R> for Vec1<T>
where
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> Vec1Segment<'_, T> {
Segment::intersect_strict_subset(&mut self.items, &range::ordered_range_offsets(range))
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/vec_deque1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ impl<T> Ranged for VecDeque<T> {
}

impl<T> Segmentation for VecDeque<T> {
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> VecDequeSegment<'_, T> {
Segment::intersect(self, &Ranged::tail(self))
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> VecDequeSegment<'_, T> {
Segment::intersect(self, &Ranged::rtail(self))
}
}
Expand All @@ -52,7 +52,7 @@ impl<T, R> segment::SegmentedBy<R> for VecDeque<T>
where
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> VecDequeSegment<'_, T> {
Segment::intersect(self, &range::ordered_range_offsets(range))
}
}
Expand Down Expand Up @@ -334,12 +334,12 @@ impl<T> IntoIterator1 for VecDeque1<T> {
}

impl<T> Segmentation for VecDeque1<T> {
fn tail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn tail(&mut self) -> VecDeque1Segment<'_, T> {
let range = Ranged::tail(&self.items);
Segment::intersect_strict_subset(&mut self.items, &range)
}

fn rtail(&mut self) -> Segment<'_, Self::Kind, Self::Target> {
fn rtail(&mut self) -> VecDeque1Segment<'_, T> {
let range = Ranged::rtail(&self.items);
Segment::intersect_strict_subset(&mut self.items, &range)
}
Expand All @@ -354,7 +354,7 @@ impl<T, R> segment::SegmentedBy<R> for VecDeque1<T>
where
R: RangeBounds<usize>,
{
fn segment(&mut self, range: R) -> Segment<'_, Self::Kind, Self::Target> {
fn segment(&mut self, range: R) -> VecDeque1Segment<'_, T> {
Segment::intersect_strict_subset(&mut self.items, &range::ordered_range_offsets(range))
}
}
Expand Down

0 comments on commit 5cdd138

Please sign in to comment.