summaryrefslogtreecommitdiff
path: root/src/util/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-12 21:36:37 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-12 22:23:08 +0200
commitc3a387b8f7086fc6d58a4175e8408fbbf375f5f2 (patch)
tree3036e9b742abe647ff47b1e4e9499a6a0fa0d096 /src/util/mod.rs
parent56968bc0d65600124774aec74348151cfbc7ea6e (diff)
Segment by script
Diffstat (limited to 'src/util/mod.rs')
-rw-r--r--src/util/mod.rs30
1 files changed, 0 insertions, 30 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs
index e42d0664..d898f545 100644
--- a/src/util/mod.rs
+++ b/src/util/mod.rs
@@ -103,12 +103,6 @@ where
/// Additional methods for slices.
pub trait SliceExt<T> {
- /// Find consecutive runs of the same elements in a slice and yield for
- /// each such run the element and number of times it appears.
- fn group(&self) -> Group<'_, T>
- where
- T: PartialEq;
-
/// Split a slice into consecutive runs with the same key and yield for
/// each such run the key and the slice of elements with that key.
fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F>
@@ -118,35 +112,11 @@ pub trait SliceExt<T> {
}
impl<T> SliceExt<T> for [T] {
- fn group(&self) -> Group<'_, T> {
- Group { slice: self }
- }
-
fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F> {
GroupByKey { slice: self, f }
}
}
-/// This struct is created by [`SliceExt::group`].
-pub struct Group<'a, T> {
- slice: &'a [T],
-}
-
-impl<'a, T> Iterator for Group<'a, T>
-where
- T: PartialEq,
-{
- type Item = (&'a T, usize);
-
- fn next(&mut self) -> Option<Self::Item> {
- let mut iter = self.slice.iter();
- let first = iter.next()?;
- let count = 1 + iter.take_while(|&t| t == first).count();
- self.slice = &self.slice[count ..];
- Some((first, count))
- }
-}
-
/// This struct is created by [`SliceExt::group_by_key`].
pub struct GroupByKey<'a, T, F> {
slice: &'a [T],