stdlib: Add ivec::any() and ivec::all(); put out burning tinderbox

This commit is contained in:
Patrick Walton
2011-07-04 23:52:47 -07:00
parent f71c8dd918
commit 001397da3c
2 changed files with 29 additions and 2 deletions

View File

@@ -171,6 +171,16 @@ fn map[T,U](fn(&T)->U f, &mutable T[mutable?] v) -> U[] {
ret result;
}
fn any[T](fn(&T)->bool f, &T[] v) -> bool {
for (T elem in v) { if (f(elem)) { ret true; } }
ret false;
}
fn all[T](fn(&T)->bool f, &T[] v) -> bool {
for (T elem in v) { if (!f(elem)) { ret false; } }
ret true;
}
mod unsafe {
fn copy_from_buf[T](&mutable T[] v, *T ptr, uint count) {