Skip to content

Commit

Permalink
get(r: Range) as Skip<Take>
Browse files Browse the repository at this point in the history
Unless there is a reason to prefer `Take<Skip>` over `Skip<Take>`?!
  • Loading branch information
Philippe-Cholet authored and jswrenn committed May 14, 2024
1 parent f676f2f commit 7a9ce56
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/iter_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ impl<I> IteratorIndex<I> for Range<usize>
where
I: Iterator,
{
type Output = Take<Skip<I>>;
type Output = Skip<Take<I>>;

fn index(self, iter: I) -> Self::Output {
iter.skip(self.start)
.take(self.end.saturating_sub(self.start))
iter.take(self.end).skip(self.start)
}
}

Expand Down

0 comments on commit 7a9ce56

Please sign in to comment.