Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ockajak committed Jul 9, 2024
1 parent 909a7bf commit a085bd6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
5 changes: 0 additions & 5 deletions src/extensions/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ impl<Item> Sequence<Item> for LinkedList<Item> {
all_unique(self.iter())
}

#[inline]
fn init(self) -> Self {
init(self.into_iter())
}

#[inline]
fn map_while<B>(&self, predicate: impl FnMut(&Item) -> Option<B>) -> Self::This<B> {
self.iter().map_while(predicate).collect()
Expand Down
5 changes: 0 additions & 5 deletions src/extensions/collections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ impl<Item> Sequence<Item> for Vec<Item> {
all_unique(self.iter())
}

#[inline]
fn init(self) -> Self {
init(self.into_iter())
}

#[inline]
fn map_while<B>(&self, predicate: impl FnMut(&Item) -> Option<B>) -> Self::This<B> {
self.iter().map_while(predicate).collect()
Expand Down
5 changes: 0 additions & 5 deletions src/extensions/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ impl<Item> Sequence<Item> for VecDeque<Item> {
all_unique(self.iter())
}

#[inline]
fn init(self) -> Self {
init(self.into_iter())
}

#[inline]
fn map_while<B>(&self, predicate: impl FnMut(&Item) -> Option<B>) -> Self::This<B> {
self.iter().map_while(predicate).collect()
Expand Down
23 changes: 11 additions & 12 deletions src/extensions/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,15 @@ pub trait Sequence<Item> {
///
/// assert_eq!(a.init(), vec![1, 2]);
/// ```
fn init(self) -> Self;
fn init<I>(self) -> Self
where
I: ExactSizeIterator<Item = Item>,
Self: IntoIterator<Item = Item, IntoIter = I> + FromIterator<Item>,
{
let iterator = self.into_iter();
let size = iterator.len() - 1;
iterator.take(size).collect()
}

fn interleave(self, elements: impl IntoIterator<Item = Item>) -> Self
where
Expand Down Expand Up @@ -716,7 +724,8 @@ pub trait Sequence<Item> {
/// assert_eq!(reversed, vec![3, 2, 1]);
/// ```
#[inline]
fn rev<I>(self) -> Self where
fn rev<I>(self) -> Self
where
I: DoubleEndedIterator<Item = Item>,
Self: IntoIterator<Item = Item, IntoIter = I> + FromIterator<Item>,
{
Expand Down Expand Up @@ -1093,16 +1102,6 @@ where
result
}

#[inline]
pub(crate) fn init<Item, Iterable, Result>(iterator: Iterable) -> Result
where
Iterable: Iterator<Item = Item> + ExactSizeIterator,
Result: FromIterator<Item>,
{
let size = iterator.len() - 1;
iterator.take(size).collect()
}

#[inline]
pub(crate) fn positions<'a, Item, Result>(
iterator: impl Iterator<Item = &'a Item>, mut predicate: impl FnMut(&Item) -> bool,
Expand Down

0 comments on commit a085bd6

Please sign in to comment.