diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 9527c85481c..3ecfe100c46 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -895,9 +895,8 @@ pub fn retain(v: &mut ~[T], f: pure fn(t: &T) -> bool) { } } - while deleted > 0 { - v.pop(); - deleted -= 1; + if deleted > 0 { + v.truncate(len - deleted); } }