Skip to content

Commit 06a336a

Browse files
committed
vec: renovate the BaseIter impl
* add 'self region to the borrowed pointer parameter * rm workaround for #2263 * inline (wrappers) * iter-trait is gone
1 parent 1cde7e6 commit 06a336a

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

src/libcore/vec.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,45 +2268,27 @@ pub mod bytes {
22682268

22692269
// ___________________________________________________________________________
22702270
// ITERATION TRAIT METHODS
2271-
//
2272-
// This cannot be used with iter-trait.rs because of the region pointer
2273-
// required in the slice.
22742271

22752272
impl<A> iter::BaseIter<A> for &self/[A] {
2276-
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
2277-
// FIXME(#2263)---should be able to call each(self, blk)
2278-
for each(*self) |e| {
2279-
if (!blk(e)) {
2280-
return;
2281-
}
2282-
}
2283-
}
2273+
#[inline(always)]
2274+
pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) }
2275+
#[inline(always)]
22842276
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
22852277
}
22862278

22872279
// FIXME(#4148): This should be redundant
22882280
impl<A> iter::BaseIter<A> for ~[A] {
2289-
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
2290-
// FIXME(#2263)---should be able to call each(self, blk)
2291-
for each(*self) |e| {
2292-
if (!blk(e)) {
2293-
return;
2294-
}
2295-
}
2296-
}
2281+
#[inline(always)]
2282+
pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) }
2283+
#[inline(always)]
22972284
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
22982285
}
22992286

23002287
// FIXME(#4148): This should be redundant
23012288
impl<A> iter::BaseIter<A> for @[A] {
2302-
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
2303-
// FIXME(#2263)---should be able to call each(self, blk)
2304-
for each(*self) |e| {
2305-
if (!blk(e)) {
2306-
return;
2307-
}
2308-
}
2309-
}
2289+
#[inline(always)]
2290+
pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) }
2291+
#[inline(always)]
23102292
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
23112293
}
23122294

0 commit comments

Comments
 (0)