Skip to content

Commit 07e4d69

Browse files
committed
iterator: work around method resolve bug (#5898)
1 parent d945543 commit 07e4d69

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libstd/iterator.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ pub trait IteratorUtil<A> {
285285
/// let a = [1, 2, 3, 4, 5];
286286
/// assert!(a.iter().last().get() == &5);
287287
/// ~~~
288-
fn last(&mut self) -> Option<A>;
288+
// FIXME: #5898: should be called `last`
289+
fn last_(&mut self) -> Option<A>;
289290

290291
/// Performs a fold operation over the entire iterator, returning the
291292
/// eventual state at the end of the iteration.
@@ -437,7 +438,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
437438

438439
/// Return the last item yielded by an iterator.
439440
#[inline(always)]
440-
fn last(&mut self) -> Option<A> {
441+
fn last_(&mut self) -> Option<A> {
441442
let mut last = None;
442443
for self.advance |x| { last = Some(x); }
443444
last
@@ -1025,8 +1026,8 @@ mod tests {
10251026
#[test]
10261027
fn test_iterator_last() {
10271028
let v = &[0, 1, 2, 3, 4];
1028-
assert_eq!(v.iter().last().unwrap(), &4);
1029-
assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0);
1029+
assert_eq!(v.iter().last_().unwrap(), &4);
1030+
assert_eq!(v.slice(0, 1).iter().last_().unwrap(), &0);
10301031
}
10311032

10321033
#[test]

0 commit comments

Comments
 (0)