Skip to content

Commit 7e3493e

Browse files
author
Jorge Aparicio
committed
libcore: use unboxed closures in the fields of Inspect
1 parent a051ba1 commit 7e3493e

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/libcore/iter.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ pub trait IteratorExt<A>: Iterator<A> {
432432
/// ```
433433
#[inline]
434434
#[unstable = "waiting for unboxed closures"]
435-
fn inspect<'r>(self, f: |&A|: 'r) -> Inspect<'r, A, Self> {
435+
fn inspect<F>(self, f: F) -> Inspect<A, Self, F> where F: FnMut(&A) {
436436
Inspect{iter: self, f: f}
437437
}
438438

@@ -777,7 +777,10 @@ pub trait ExactSizeIterator<A> : DoubleEndedIterator<A> {
777777
#[unstable = "trait is unstable"]
778778
impl<A, T: ExactSizeIterator<A>> ExactSizeIterator<(uint, A)> for Enumerate<T> {}
779779
#[unstable = "trait is unstable"]
780-
impl<'a, A, T: ExactSizeIterator<A>> ExactSizeIterator<A> for Inspect<'a, A, T> {}
780+
impl<A, I, F> ExactSizeIterator<A> for Inspect<A, I, F> where
781+
I: ExactSizeIterator<A>,
782+
F: FnMut(&A),
783+
{}
781784
#[unstable = "trait is unstable"]
782785
impl<A, T: ExactSizeIterator<A>> ExactSizeIterator<A> for Rev<T> {}
783786
#[unstable = "trait is unstable"]
@@ -2012,12 +2015,12 @@ impl<T> Fuse<T> {
20122015
/// element before yielding it.
20132016
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
20142017
#[unstable = "waiting for unboxed closures"]
2015-
pub struct Inspect<'a, A, T> {
2016-
iter: T,
2017-
f: |&A|: 'a
2018+
pub struct Inspect<A, I, F> where I: Iterator<A>, F: FnMut(&A) {
2019+
iter: I,
2020+
f: F,
20182021
}
20192022

2020-
impl<'a, A, T> Inspect<'a, A, T> {
2023+
impl<A, I, F> Inspect<A, I, F> where I: Iterator<A>, F: FnMut(&A) {
20212024
#[inline]
20222025
fn do_inspect(&mut self, elt: Option<A>) -> Option<A> {
20232026
match elt {
@@ -2030,7 +2033,7 @@ impl<'a, A, T> Inspect<'a, A, T> {
20302033
}
20312034

20322035
#[unstable = "trait is unstable"]
2033-
impl<'a, A, T: Iterator<A>> Iterator<A> for Inspect<'a, A, T> {
2036+
impl<A, I, F> Iterator<A> for Inspect<A, I, F> where I: Iterator<A>, F: FnMut(&A) {
20342037
#[inline]
20352038
fn next(&mut self) -> Option<A> {
20362039
let next = self.iter.next();
@@ -2044,8 +2047,10 @@ impl<'a, A, T: Iterator<A>> Iterator<A> for Inspect<'a, A, T> {
20442047
}
20452048

20462049
#[unstable = "trait is unstable"]
2047-
impl<'a, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A>
2048-
for Inspect<'a, A, T> {
2050+
impl<A, I, F> DoubleEndedIterator<A> for Inspect<A, I, F> where
2051+
I: DoubleEndedIterator<A>,
2052+
F: FnMut(&A),
2053+
{
20492054
#[inline]
20502055
fn next_back(&mut self) -> Option<A> {
20512056
let next = self.iter.next_back();
@@ -2054,8 +2059,10 @@ for Inspect<'a, A, T> {
20542059
}
20552060

20562061
#[experimental = "trait is experimental"]
2057-
impl<'a, A, T: RandomAccessIterator<A>> RandomAccessIterator<A>
2058-
for Inspect<'a, A, T> {
2062+
impl<A, I, F> RandomAccessIterator<A> for Inspect<A, I, F> where
2063+
I: RandomAccessIterator<A>,
2064+
F: FnMut(&A),
2065+
{
20592066
#[inline]
20602067
fn indexable(&self) -> uint {
20612068
self.iter.indexable()

0 commit comments

Comments
 (0)