about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ivec.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs
index 6e32901a437..6101163d32d 100644
--- a/src/lib/ivec.rs
+++ b/src/lib/ivec.rs
@@ -208,6 +208,12 @@ fn member[T](&T x, &T[] v) -> bool {
     ret false;
 }
 
+fn count[T](&T x, &T[mutable?] v) -> uint {
+    auto cnt = 0u;
+    for (T elt in v) { if (x == elt) { cnt += 1u; } }
+    ret cnt;
+}
+
 fn find[T](fn(&T) -> bool  f, &T[] v) -> option::t[T] {
     for (T elt in v) { if (f(elt)) { ret some[T](elt); } }
     ret none[T];